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

body {
    font-family: 'Roboto', Arial, sans-serif;
    background: #2a2a2a;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
}

/* App Wrapper */
.app-wrapper {
    width: 100%;
    /* max-width: 1200px; removed to make it full width */
    background: #f0f0f0;
    border: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Title Bar */
.title-bar {
    background: linear-gradient(180deg, #1a4fa0 0%, #1a3a8a 100%);
    color: white;
    text-align: center;
    padding: 12px 20px 8px;
    border-bottom: 3px solid #0d2a6b;
    position: relative; /* For absolutely positioning the Add button */
}

.title-bar h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.subtitle-bar {
    font-size: 13px;
    color: #b0c8f0;
    letter-spacing: 1px;
    margin-top: 2px;
}

/* App Body */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden; /* Prevent body scroll if content is long, scroll inside main */
}

/* Global Add Button (Top Right) */
.global-add-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: #1a7a30; /* Green */
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: transform 0.2s, background 0.2s;
    z-index: 100;
}

.global-add-btn:hover {
    background: #145e24;
    transform: translateY(-50%) scale(1.05);
}

.global-add-btn.clear-data-btn {
    right: 60px;
    background: rgba(255, 255, 255, 0.2);
}
.global-add-btn.clear-data-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.clear-data-group {
    margin-bottom: 14px;
}
.clear-data-main {
    font-weight: 600;
    color: #1a4fa0;
    margin-bottom: 6px;
    font-size: 14px;
}
.clear-data-subheading {
    font-size: 12px;
    color: #6b7280;
    margin: 8px 0 4px;
    padding-left: 4px;
}
.clear-data-item.clear-data-main-option {
    font-weight: 500;
}
.clear-data-item {
    display: block;
    padding: 4px 0 4px 20px;
    cursor: pointer;
    font-size: 14px;
}
.clear-data-item input {
    margin-right: 8px;
}

/* Sidebar */
.sidebar {
    width: 175px;
    background: #1a4fa0;
    flex-shrink: 0;
    padding: 6px 0;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav ul li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #d0e4ff;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 400;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    transition: background 0.15s;
}

.sidebar nav ul li a i {
    width: 16px;
    font-size: 12px;
    opacity: 0.85;
}

.sidebar nav ul li.active a,
.sidebar nav ul li a:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

.sidebar nav ul li.active a {
    background: rgba(255,255,255,0.22);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 6px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: auto; /* Allow scrolling inside the dashboard */
    background: #e4e9f0; /* Slight gray/blue background for the main area */
}

/* App View Toggle */
.app-view {
    display: none;
    flex-direction: column;
    gap: 6px;
}
.app-view.active {
    display: flex;
}

/* Full Page Panels inside views */
.page-layout {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
}
.full-page-panel {
    background: white;
    border: 1px solid #c5c5c5;
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.full-page-panel .panel-title,
.full-page-panel .panel-title-row {
    font-size: 14px;
    padding: 10px 15px;
    background: #f0f4f8;
}

.full-page-panel .data-table {
    font-size: 13px;
}

.full-page-panel .data-table th,
.full-page-panel .data-table td {
    padding: 10px 15px;
}

/* Dashboard Header */
.dashboard-header {
    background: white;
    border: 1px solid #ccc;
    border-radius: 3px;
    text-align: center;
    padding: 6px;
}

.dashboard-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: #1a4fa0;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Summary Row */
.summary-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
}

.summary-card {
    border-radius: 4px;
    padding: 8px 10px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-card.blue-card  { background: linear-gradient(135deg, #1e6fc4, #1a4fa0); color: white; }
.summary-card.teal-card  { background: linear-gradient(135deg, #1a8fa0, #156880); color: white; }
.summary-card.green-card { background: linear-gradient(135deg, #28a044, #1a7a30); color: white; }
.summary-card.white-card { background: #fff; color: #222; border: 1px solid #ccc; }
.summary-card.yellow-card { background: linear-gradient(135deg, #d4a017, #b8860b); color: white; }

.summary-card.js-balance-card:hover { filter: brightness(1.08); transform: translateY(-1px); }
.summary-card.js-balance-card { transition: filter 0.15s, transform 0.15s; }

.card-label {
    font-size: 10.5px;
    font-weight: 500;
    opacity: 0.9;
    line-height: 1.2;
}

.card-amount {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: white;
}

.card-amount.dark { color: #1a4fa0; font-size: 16px; }

.card-icon-wrap {
    position: absolute;
    right: 8px;
    bottom: 6px;
    font-size: 22px;
    opacity: 0.4;
    color: white;
}

.card-icon-wrap.small { font-size: 18px; color: #1a4fa0; }

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 185px 1fr 195px 175px;
    grid-template-rows: auto auto auto;
    gap: 6px;
}

/* Row 1 */
.account-balances  { grid-column: 1; grid-row: 1; }
.csp-management    { grid-column: 2; grid-row: 1; }
.staff-cash        { grid-column: 3; grid-row: 1; }
.shop-income       { grid-column: 4; grid-row: 1; }

/* Row 2 */
.expense-manager   { grid-column: 1 / span 1; grid-row: 2; }
.borrow-lend       { grid-column: 2; grid-row: 2; }
.loan-emi          { grid-column: 3; grid-row: 2; }
.reports-panel     { grid-column: 4; grid-row: 2; }

/* Row 3 */
.repurts-panel     { grid-column: 1; grid-row: 3; }
.cable-broadband   { grid-column: 2; grid-row: 3; }
.share-market      { grid-column: 3; grid-row: 3; }
.notes-panel       { grid-column: 4; grid-row: 3; }

/* Panels */
.panel {
    background: white;
    border: 1px solid #c5c5c5;
    border-radius: 3px;
    overflow: hidden;
}

.panel-title {
    font-size: 11px;
    font-weight: 700;
    color: #1a4fa0;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 5px 8px 4px;
    border-bottom: 1px solid #ddd;
    background: #f8f9fc;
}

.panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px 4px;
    border-bottom: 1px solid #ddd;
    background: #f8f9fc;
}

.panel-title-row .panel-title {
    padding: 0;
    border: none;
    background: none;
}

/* Add Button */
.add-btn {
    background: #1a6fcc;
    color: white;
    border: none;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.add-btn:hover { background: #1455a0; }

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
}

.data-table th {
    background: #e8eef7;
    color: #1a4fa0;
    font-size: 10.5px;
    font-weight: 600;
    padding: 4px 6px;
    text-align: center;
    border-bottom: 1px solid #ccc;
    border-right: 1px solid #ddd;
    white-space: nowrap;
}

.data-table th:last-child { border-right: none; }

.data-table td {
    padding: 4px 7px;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #eee;
    color: #333;
    white-space: nowrap;
}

.data-table td:last-child { border-right: none; }

.data-table tbody tr:hover { background: #f5f8ff; }

.amount-right {
    text-align: right;
    font-weight: 500;
    color: #1a3a80;
}

.th-style {
    font-weight: 600;
    color: #1a4fa0;
    background: #e8eef7;
}

.profit-green {
    color: #1a7a30;
    font-weight: 600;
    text-align: right;
    background: #eafaf0;
}

.profit-red {
    color: #cc2200;
    font-weight: 600;
    text-align: right;
    background: #faeaea;
}

.bold { font-weight: 700; }

/* Status Icons */
.status-green {
    color: #1a7a30;
    font-size: 14px;
}

/* Reports Panel */
.report-list {
    list-style: none;
    padding: 4px 0;
}

.report-list li {
    padding: 5px 10px;
    font-size: 12px;
    color: #222;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.report-list li:hover { background: #f0f5ff; }

.report-icon {
    color: #1a6fcc;
    font-size: 10px;
}

/* Notes Panel */
.notes-list {
    list-style: none;
    padding: 4px 0;
}

.notes-list li {
    padding: 6px 10px;
    font-size: 12px;
    color: #222;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-item {
    list-style: none;
    margin-left: -20px;
    padding-left: 20px;
}

.notes-item-body {
    flex: 1;
    word-break: break-word;
}

.notes-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.notes-btn-edit,
.notes-btn-delete {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #6b7280;
    font-size: 12px;
    transition: color 0.2s;
}

.notes-btn-edit:hover { color: #1a6fcc; }
.notes-btn-delete:hover { color: #dc2626; }

.notes-empty {
    list-style: none;
    margin-left: -20px;
    padding-left: 20px;
    color: #6b7280;
    font-style: italic;
}

.note-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.note-dot.orange { background: #e07800; }

/* Footer Row */
.footer-row {
    background: white;
    border: 1px solid #ccc;
    border-radius: 3px;
    display: flex;
    align-items: center;
    padding: 8px 14px;
    gap: 10px;
}

.footer-left, .footer-center {
    flex: 1;
}

.footer-label {
    font-size: 12px;
    font-weight: 600;
    color: #1a4fa0;
}

.footer-right {
    display: flex;
    gap: 10px;
}

.footer-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 20px;
    border: none;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.footer-btn:hover { opacity: 0.85; }

.backup-btn {
    background: #1a6fcc;
    color: white;
}

.login-btn {
    background: #1a7a30;
    color: white;
}

/* Responsive */
@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
    }
    .account-balances, .csp-management, .staff-cash, .shop-income,
    .expense-manager, .borrow-lend, .loan-emi, .reports-panel,
    .repurts-panel, .cable-broadband, .share-market, .notes-panel {
        grid-column: auto;
        grid-row: auto;
    }
    .summary-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* --- Modal Styles (Restored) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.6); /* Darker backdrop */
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #ffffff;
    width: 450px;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    color: #333;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-content-narrow {
    width: 420px;
    max-width: 95vw;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fc;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #1a4fa0;
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.close-btn:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    color: #111827;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #f9fafb;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.form-group select {
    /* Custom arrow for select */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    cursor: pointer;
    /* User requested dark mode aesthetic on options, achievable gracefully through color-scheme */
    color-scheme: light dark;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a6fcc;
    box-shadow: 0 0 0 3px rgba(26, 111, 204, 0.15);
    background-color: #ffffff;
}

.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    color: #111827;
    resize: vertical;
    min-height: 80px;
    background-color: #f9fafb;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group textarea:focus {
    outline: none;
    border-color: #1a6fcc;
    box-shadow: 0 0 0 3px rgba(26, 111, 204, 0.15);
    background-color: #ffffff;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 14px;
    color: #6b7280;
    font-weight: 600;
    font-size: 16px;
}

.input-with-icon input {
    padding-left: 32px !important;
    font-size: 16px !important;
    font-weight: 500;
}

/* Type Toggle Switch */
.type-toggle {
    display: flex;
    background-color: #f3f4f6;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}

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

.toggle-btn {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    color: #6b7280;
    transition: all 0.2s ease;
    margin-bottom: 0 !important;
}

#typeIncome:checked ~ .income-toggle {
    background-color: #1a7a30;
    color: white;
    box-shadow: 0 2px 4px rgba(26, 122, 48, 0.2);
}

#typeExpense:checked ~ .expense-toggle {
    background-color: #ef4444;
    color: white;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.submit-btn {
    width: 100%;
    background-color: #1a6fcc;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    transition: all 0.2s;
    margin-top: 8px;
    box-shadow: 0 4px 6px rgba(26, 111, 204, 0.2);
}

.submit-btn:hover {
    background-color: #1455a0;
    transform: translateY(-1px);
    box-shadow: 0 6px 10px rgba(26, 111, 204, 0.3);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.panel-hint {
    font-size: 13px;
    color: #6b7280;
    margin: 4px 0 8px;
}

.text-muted {
    color: #6b7280;
    font-style: italic;
    padding: 12px 8px;
}

.data-table tbody tr.empty-row td {
    text-align: center;
}

.data-table tfoot .total-row td {
    border-top: 2px solid #374151;
    padding-top: 10px;
    background: rgba(0, 0, 0, 0.05);
}

/* ========== Auth pages (login & register) ========== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #020617 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.auth-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 20% 80%, rgba(26, 111, 204, 0.08) 0%, transparent 50%),
                      radial-gradient(circle at 80% 20%, rgba(26, 111, 204, 0.06) 0%, transparent 45%);
    pointer-events: none;
}
.auth-card {
    background: #ffffff;
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
    overflow: hidden;
    position: relative;
    z-index: 1;
    animation: authCardIn 0.4s ease-out;
}
.auth-card.auth-card-wide {
    max-width: 450px;
}
@keyframes authCardIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.auth-header {
    background: linear-gradient(135deg, #1e5bb8 0%, #1a4fa0 50%, #153d7a 100%);
    color: white;
    text-align: center;
    padding: 28px 24px;
    border-bottom: none;
    position: relative;
}
.auth-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    opacity: 0.8;
}
.auth-header h1 {
    font-family: 'DM Sans', 'Roboto', sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    margin-bottom: 6px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.auth-header p {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.88);
    letter-spacing: 0.5px;
}
.auth-body {
    padding: 32px 28px;
}
.auth-body .form-group {
    margin-bottom: 20px;
}
.auth-body .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}
.auth-input-wrap {
    position: relative;
    display: block;
}
.auth-input-wrap .auth-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 15px;
    pointer-events: none;
    transition: color 0.2s;
}
.auth-input-wrap input:focus ~ .auth-input-icon,
.auth-input-wrap:focus-within .auth-input-icon {
    color: #1a6fcc;
}
.auth-body .auth-input-wrap input,
.auth-body .form-group input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    color: #111827;
    background: #f9fafb;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing: border-box;
}
.auth-body .form-group input::placeholder {
    color: #9ca3af;
}
.auth-body .auth-input-wrap input:focus,
.auth-body .form-group input:focus {
    outline: none;
    border-color: #1a6fcc;
    box-shadow: 0 0 0 3px rgba(26, 111, 204, 0.12);
    background: #fff;
}
.auth-body .submit-btn {
    width: 100%;
    margin-top: 8px;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.auth-body .submit-btn:active {
    transform: translateY(0);
}
.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f3f4f6;
    font-size: 13px;
    color: #6b7280;
}
.auth-footer a {
    color: #1a6fcc;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s;
}
.auth-footer a:hover {
    color: #0d4a8f;
    text-decoration: underline;
}
.alert-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #b91c1c;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 20px;
    border: 1px solid #fecaca;
}
.alert-error ul {
    margin: 0;
    padding-left: 20px;
}
