/* Reset and Variables */
:root {
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Layout Constants */
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
}

/* Dark Theme Colors */
body.dark-theme {
    --bg-primary: #0b0f19;
    --bg-secondary: #131b2e;
    --bg-tertiary: #1e293b;
    --glass-bg: rgba(19, 27, 46, 0.8);
    --glass-border: rgba(255, 255, 255, 0.06);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --danger: #f43f5e;
    --danger-light: rgba(244, 63, 94, 0.15);
    --border: #1e293b;
    --border-highlight: #334155;
    --shadow: rgba(0, 0, 0, 0.5);
    --card-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.6);
    --glow-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* Light Theme Colors */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.05);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --primary: #4f46e5;
    --primary-hover: #3730a3;
    --accent: #d97706;
    --accent-hover: #b45309;
    --success: #059669;
    --success-light: rgba(5, 150, 105, 0.1);
    --danger: #e11d48;
    --danger-light: rgba(225, 29, 72, 0.1);
    --border: #e2e8f0;
    --border-highlight: #cbd5e1;
    --shadow: rgba(0, 0, 0, 0.04);
    --card-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.08);
    --glow-shadow: 0 0 20px rgba(79, 70, 229, 0.08);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans Thai', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Utility classes */
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

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

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: background-color var(--transition-normal), border var(--transition-normal);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.brand-icon i {
    width: 22px;
    height: 22px;
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

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

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.menu-item i {
    width: 20px;
    height: 20px;
}

.menu-item:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    transform: translateX(4px);
}

.menu-item.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), rgba(99, 102, 241, 0.8));
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Theme Switcher Button */
#theme-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

#theme-toggle-btn:hover {
    color: var(--text-primary);
    background-color: var(--border-highlight);
}

.sun-icon { display: none; }
.moon-icon { display: block; }

body.light-theme .sun-icon { display: block; }
body.light-theme .moon-icon { display: none; }

.backup-restore-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Main Content Styling */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 32px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Content Header */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

.header-title h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.header-title p {
    font-size: 0.9rem;
}

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

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-accent {
    background-color: var(--accent);
    color: #ffffff;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}

.btn-success:hover {
    background-color: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
}

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

.btn-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeIn var(--transition-normal);
}

.tab-panel.active {
    display: block;
}

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

/* Dashboard Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.metric-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.metric-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-highlight);
    box-shadow: var(--glow-shadow), var(--card-shadow);
}

.card-gradient-1::after,
.card-gradient-2::after,
.card-gradient-3::after,
.card-gradient-4::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.12;
    z-index: 1;
    pointer-events: none;
}

.card-gradient-1::after { background: var(--primary); }
.card-gradient-2::after { background: var(--danger); }
.card-gradient-3::after { background: var(--success); }
.card-gradient-4::after { background: var(--accent); }

.card-icon {
    width: 52px;
    height: 52px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    z-index: 2;
}

.card-icon i {
    width: 24px;
    height: 24px;
}

.card-icon .icon-danger { color: var(--danger); }
.card-icon .icon-success { color: var(--success); }

.metric-info {
    flex-grow: 1;
    z-index: 2;
}

.metric-info h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 4px;
}

.metric-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Progress bar inside metric */
.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-full);
    margin: 8px 0;
    overflow: hidden;
}

.progress-bar-container.lg {
    height: 10px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dashboard Secondary Layout Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: background-color var(--transition-normal), border var(--transition-normal);
}

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

.card-header h4 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-content {
    padding: 24px;
}

.chart-card .chart-container {
    position: relative;
    height: 280px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-data-msg {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-style: italic;
}

/* Upcoming Due Debts Widget */
.upcoming-debts-card {
    grid-column: 1 / -1; /* Stretch across all columns */
}

.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 4px;
}

.upcoming-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    border-left: 4px solid var(--accent);
    transition: all var(--transition-fast);
}

.upcoming-item.overdue {
    border-left-color: var(--danger);
    background-color: rgba(244, 63, 94, 0.04);
}

.upcoming-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.upcoming-main {
    display: flex;
    align-items: center;
    gap: 14px;
}

.upcoming-avatar {
    width: 40px;
    height: 40px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
    border: 1px solid var(--border);
}

.upcoming-title {
    font-size: 0.92rem;
    font-weight: 600;
}

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

.upcoming-finance {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.upcoming-amount {
    font-weight: 700;
    font-size: 1.05rem;
}

.upcoming-due {
    font-size: 0.78rem;
    font-weight: 500;
}

.bell-glow {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(245, 158, 11, 0.4)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.8)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(245, 158, 11, 0)); }
}

/* Actions Row in Sections */
.section-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.filters-group {
    display: flex;
    gap: 12px;
    flex-grow: 1;
    max-width: 600px;
}

.search-box {
    position: relative;
    flex-grow: 1;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    height: 44px;
    padding: 0 16px 0 44px;
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.92rem;
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Form Select / Control Style */
.form-select {
    height: 44px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    outline: none;
    font-size: 0.92rem;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-select:focus {
    border-color: var(--primary);
}

/* Creditors Tab Components */
.creditors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.creditor-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    transition: all var(--transition-normal);
}

.creditor-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-highlight);
    box-shadow: 0 8px 20px -5px rgba(0,0,0,0.3);
}

.creditor-card-header {
    display: flex;
    gap: 14px;
    align-items: center;
}

.creditor-icon-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--bg-tertiary), var(--border));
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    border: 1px solid var(--border);
}

.creditor-card-title {
    flex-grow: 1;
}

.creditor-card-title h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.creditor-card-title span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.creditor-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}

.creditor-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.creditor-contact-item i {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.creditor-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

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

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    color: var(--text-primary);
    background-color: var(--border-highlight);
}

.btn-icon-danger:hover {
    background-color: var(--danger-light);
    color: var(--danger);
    border-color: rgba(244, 63, 94, 0.3);
}

/* Debts Tab Table */
.table-container {
    width: 100%;
    overflow-x: auto;
    background-color: var(--bg-secondary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.92rem;
}

.data-table th {
    background-color: var(--bg-secondary);
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.02);
}

.debt-title-cell {
    font-weight: 600;
}

.debt-sub-cell {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pending {
    background-color: rgba(245, 158, 11, 0.12);
    color: var(--accent);
}

.status-partial {
    background-color: rgba(99, 102, 241, 0.12);
    color: var(--primary);
}

.status-paid {
    background-color: var(--success-light);
    color: var(--success);
}

.table-empty-state, .empty-state {
    padding: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    width: 48px;
    height: 48px;
    stroke-width: 1.5;
}

/* Payments Timeline/History Tab */
.timeline-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
}

.timeline {
    position: relative;
    border-left: 2px solid var(--border);
    padding-left: 32px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.timeline-item {
    position: relative;
}

.timeline-dot {
    position: absolute;
    left: -43px;
    top: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--success);
    border: 4px solid var(--bg-primary);
    box-shadow: 0 0 0 2px var(--success-light);
}

.timeline-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--card-shadow);
    position: relative;
}

.timeline-content::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 10px;
    width: 14px;
    height: 14px;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transform: rotate(45deg);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.timeline-title h4 {
    font-size: 0.95rem;
    font-weight: 700;
}

.timeline-title span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.timeline-amount {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--success);
}

.timeline-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-top: 1px dashed var(--border);
    padding-top: 12px;
}

.timeline-meta-row {
    display: flex;
    gap: 20px;
}

.timeline-meta-row span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-meta-row i {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

/* Modals System */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    background-color: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform var(--transition-normal);
}

.modal.show .modal-dialog {
    transform: scale(1);
}

.modal-lg {
    max-width: 800px;
}

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--transition-fast);
    line-height: 1;
}

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

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

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

/* Form Styles inside Modals */
.form-group {
    margin-bottom: 18px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 18px;
}

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

.col-6 { width: calc(50% - 8px); }
.col-12 { width: 100%; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group label span.required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    outline: none;
    font-size: 0.92rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--primary);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

textarea.form-control {
    resize: vertical;
}

.form-help-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-help-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.form-help-text a:hover {
    text-decoration: underline;
}

.highlight-input {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

/* Modal specific views: Payment brief */
.debt-summary-panel {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.debt-summary-title {
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 8px;
}

.debt-summary-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    gap: 12px;
}

/* Debt Details View Grid */
.debt-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}

.detail-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-box.full-width {
    grid-column: 1 / -1;
    border-top: 1px dashed var(--border);
    padding-top: 12px;
    margin-top: 4px;
}

.detail-box .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.detail-box .value {
    font-size: 0.95rem;
    font-weight: 600;
}

/* Progress banner */
.debt-progress-dashboard {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 28px;
    background-color: var(--bg-secondary);
}

.status-banner {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.progress-item {
    display: flex;
    flex-direction: column;
}

.progress-item span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.progress-item strong {
    font-size: 1.25rem;
    font-weight: 800;
}

/* Installments Sub-table */
.installments-section {
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.installments-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.installments-section h4 {
    font-size: 0.95rem;
    font-weight: 700;
}

.table-container.sm {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.table-container.sm .data-table th {
    padding: 10px 14px;
    background-color: var(--bg-tertiary);
}

.table-container.sm .data-table td {
    padding: 10px 14px;
    font-size: 0.85rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 999;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    min-width: 300px;
    max-width: 450px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--accent); }

.toast-message {
    flex-grow: 1;
    font-size: 0.88rem;
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

/* Responsive Styling for Mobile */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 16px 20px;
    }

    .sidebar-brand {
        margin-bottom: 16px;
    }

    .sidebar-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .menu-item {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .sidebar-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 16px;
        padding-top: 12px;
    }

    .backup-restore-actions {
        width: auto;
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .col-6 {
        width: 100%;
    }
}

/* Progress Bar small inside table cell */
.progress-bar-container.sm {
    height: 6px;
    margin: 4px 0 0 0;
    width: 100%;
}

.progress-text-sm {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Report Styles */
.report-print-area {
    padding: 24px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.report-header-sheet {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--border);
    padding-bottom: 20px;
    margin-bottom: 24px;
}

.report-title-section h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
}

.report-title-section p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.report-brand-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.report-brand-meta strong {
    font-size: 1.1rem;
    color: var(--primary);
}

.report-brand-meta span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.report-summary-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.report-stat-box {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-stat-box span {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.report-stat-box strong {
    font-size: 1.35rem;
    font-weight: 800;
}

.report-table-wrapper {
    overflow-x: auto;
}

.report-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.report-data-table th {
    background-color: var(--bg-tertiary);
    padding: 10px 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
}

.report-data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.report-debt-row {
    background-color: rgba(99, 102, 241, 0.02);
}

.report-payments-subrow {
    background-color: rgba(0, 0, 0, 0.05);
}

.report-sub-payments-table {
    width: 100%;
    margin: 8px 0;
    border-collapse: collapse;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.report-sub-payments-table th {
    background-color: var(--bg-secondary);
    padding: 6px 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.report-sub-payments-table td {
    padding: 6px 12px;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

/* Print Specific Rules */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-size: 11pt !important;
    }

    /* Hide elements not needed for print */
    .sidebar,
    .main-content > .content-header,
    .section-actions-row,
    .modal-header,
    .modal-footer,
    .no-print,
    #toast-container {
        display: none !important;
    }

    /* Modal override to act as a normal page block */
    .modal {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        background: none !important;
        backdrop-filter: none !important;
        display: block !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: auto !important;
        padding: 0 !important;
    }

    .modal-dialog {
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        background: none !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
    }

    .modal-body {
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .report-print-area {
        background: none !important;
        border: none !important;
        padding: 0 !important;
        color: #000000 !important;
    }

    .report-header-sheet {
        border-bottom-color: #000000 !important;
    }

    .report-title-section h2 {
        color: #000000 !important;
    }

    .report-brand-meta strong {
        color: #000000 !important;
    }

    .report-stat-box {
        background-color: #f8fafc !important;
        border-color: #e2e8f0 !important;
        color: #000000 !important;
    }

    .report-stat-box strong {
        color: #000000 !important;
    }

    .report-data-table th {
        background-color: #f1f5f9 !important;
        color: #000000 !important;
        border-bottom-color: #000000 !important;
    }

    .report-data-table td {
        border-bottom-color: #cbd5e1 !important;
        color: #000000 !important;
    }

    .report-sub-payments-table th {
        background-color: #f8fafc !important;
        color: #000000 !important;
        border-bottom-color: #cbd5e1 !important;
    }

    .report-sub-payments-table td {
        background-color: #ffffff !important;
        color: #334155 !important;
        border-bottom-color: #e2e8f0 !important;
    }

    .status-indicator {
        border: 1px solid #cbd5e1 !important;
        background: none !important;
        color: #000000 !important;
    }
}
