body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
    line-height: 1.6;
}

.header {
    background-color: #23403B;
    color: #f0f0f0;
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    margin: 0;
    font-size: 1.5em;
    text-align: left;
}

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

.header-actions button {
    background-color: #69C99F;
    color: #23403B;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

.header-actions button:hover {
    background-color: #6D9E89;
}

.main-nav {
    background-color: #f0f0f0;
    border-bottom: 1px solid #ccc;
}

.tab-buttons-header {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
}

.tab-button {
    background-color: transparent;
    border: none;
    color: #555;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1em;
    transition: color 0.3s ease;
}

.tab-button:hover {
    color: #333;
}

.tab-button.active {
    color: #23403B;
    border-bottom: 2px solid #23403B;
    font-weight: bold;
}

.tab-container {
    margin-top: 20px;
}

.tab-buttons {
    display: flex;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ccc;
    display: none;
}

.tab-content {
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    max-width: 95%;
    display: none;
}

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

.input-form,
.expense-form,
#account-input-container {
    margin: 20px 0;
    padding: 20px;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.input-form h2,
.expense-form h2,
#account-input-container h2 {
    color: #23403B;
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
}

.input-form label,
.expense-form label,
.account-form label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: bold;
}

.input-form input[type="number"],
.input-form input[type="text"],
.input-form select,
.expense-form input[type="number"],
.expense-form input[type="text"],
.expense-form select,
.account-form input[type="text"],
.account-form input[type="number"] {
    width: calc(100% - 16px);
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
}

.input-form button,
.expense-form button,
.account-form button {
    background-color: #69C99F;
    color: #23403B;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
    display: block;
    width: 100%;
    margin-top: 10px;
}

.input-form button:hover,
.expense-form button:hover,
.account-form button:hover {
    background-color: #6D9E89;
}

#income-table-container,
#expense-table-container,
#accounts-section > div,
#expense-analysis-container,
#category-analysis-table-container {
    margin: 20px 0;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    max-width: 95%;
}

#income-table-container h2,
#expense-table-container h2,
#accounts-section h2,
#accounts-section > div > h3,
#expense-analysis-container h2,
#category-analysis-table-container h2 {
    color: #23403B;
    padding: 15px;
    margin-top: 0;
    text-align: center;
    background-color: #f9f9f9;
    border-bottom: 1px solid #eee;
}

#accounts-section > div > h3 {
    text-align: left;
    padding-left: 20px;
    background-color: transparent;
    border-bottom: none;
    margin-top: 20px;
}

#income-table,
#expense-table,
#accounts-section table,
#expense-analysis-table,
#category-analysis-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

#income-table th, #income-table td,
#expense-table th, #expense-table td,
#accounts-section th, #accounts-section td,
#expense-analysis-table th, #expense-analysis-table td,
#category-analysis-table th, #category-analysis-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
    white-space: nowrap;
}

#income-table th,
#expense-table th,
#accounts-section th,
#expense-analysis-table th,
#category-analysis-table th {
    background-color: #637A6C;
    color: #f0f0f0;
    font-weight: bold;
}

#income-table tbody tr:nth-child(even),
#expense-table tbody tr:nth-child(even),
#accounts-section tbody tr:nth-child(even),
#expense-analysis-table tbody tr:nth-child(even),
#category-analysis-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: flex-start;
}

.action-buttons button {
    background-color: #ddd;
    color: #333;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
}

.action-buttons button:hover {
    background-color: #ccc;
}

.edit-button {
    background-color: #6D9E89;
    color: #fff;
}

.edit-button:hover {
    background-color: #5a8273;
}

.delete-button {
    background-color: #d9534f;
    color: #fff;
}

.delete-button:hover {
    background-color: #c9302c;
}

.save-button {
    background-color: #5cb85c;
    color: #fff;
}

.save-button:hover {
    background-color: #4cae4c;
}

.cancel-button {
    background-color: #f0ad4e;
    color: #fff;
}

.cancel-button:hover {
    background-color: #eea236;
}

#frequency-summary,
#expense-summary,
#net-position-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 20px 0;
    max-width: 95%;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

#frequency-summary h2,
#expense-summary h2,
#net-position-summary h2 {
    color: #23403B;
    width: 100%;
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
}

#frequency-summary-details,
#expense-summary-details,
#net-position-summary-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

.summary-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    min-width: 150px;
    box-shadow: 2px 2px 5px #eee;
    text-align: center;
    background-color: #f9f9f9;
    flex-grow: 1;
}

.summary-card h3 {
    margin-top: 0;
    color: #555;
    font-size: 1.1em;
    margin-bottom: 8px;
}

.summary-card p {
    color: #23403B;
    font-size: 1.2em;
    font-weight: bold;
}

.summary-card p.positive {
    color: green;
}

.summary-card p.negative {
    color: red;
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .header h1 {
        text-align: left;
        margin-bottom: 10px;
    }

    .tab-buttons-header {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .tab-button {
        margin-right: 5px;
        margin-bottom: 5px;
    }

    #header-calculations {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
    }

    #net-position {
        width: 100%;
        justify-content: flex-start;
    }

    .input-form,
    .expense-form,
    #account-input-container,
    #income-table-container,
    #expense-table-container,
    #accounts-section > div,
    #expense-analysis-container,
    #category-analysis-table-container,
    #frequency-summary,
    #expense-summary,
    #net-position-summary {
        margin-left: 10px;
        margin-right: 10px;
    }

    .summary-card {
        width: calc(50% - 20px);
    }

    #income-table,
    #expense-table,
    #accounts-section table,
    #expense-analysis-table,
    #category-analysis-table {
        font-size: 0.9em;
    }

    #income-table th, #income-table td,
    #expense-table th, #expense-table td,
    #accounts-section th, #accounts-section td,
    #expense-analysis-table th, #expense-analysis-table td,
    #category-analysis-table th, #category-analysis-table td {
        padding: 8px;
    }

    .action-buttons button {
        padding: 6px 10px;
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    .header {
        align-items: center;
    }

    .header h1 {
        text-align: center;
    }

    .tab-buttons-header {
        flex-direction: column;
        align-items: stretch;
    }

    .tab-button {
        margin-right: 0;
        margin-bottom: 5px;
        display: block;
        text-align: center;
    }

    .summary-card {
        width: calc(100% - 20px);
    }
}

#expense-analysis-table th {
    position: relative;
    padding-right: 1.5em;
}

#expense-analysis-table th::after {
    content: 'v';
    position: absolute;
    right: 0.5em;
    top: 50%;
    transform: translateY(-50%);
    color: #ddd;
    font-size: 0.8em;
}

#expense-analysis-table th.sorted-asc::after {
    content: '^';
    color: #fff;
}

#expense-analysis-table th.sorted-desc::after {
    content: 'v';
    color: #fff;
}

#category-analysis-table,
    #time-until-no-money-table {
        font-size: 0.9em;
    }

    #income-table th, #income-table td,
    #expense-table th, #expense-table td,
    #accounts-section th, #accounts-section td,
    #expense-analysis-table th, #expense-analysis-table td,
    #category-analysis-table th, #category-analysis-table td,
    #time-until-no-money-table th, #time-until-no-money-table td {
        padding: 8px;
    }

    .action-buttons button {
        padding: 6px 10px;
        font-size: 0.8em;
    }

@media (max-width: 480px) {
    .header {
        align-items: center;
    }

    .header h1 {
        text-align: center;
    }

    .tab-buttons-header {
        flex-direction: column;
        align-items: stretch;
    }

    .tab-button {
        margin-right: 0;
        margin-bottom: 5px;
        display: block;
        text-align: center;
    }

    .summary-card {
        width: calc(100% - 20px);
    }

    .financial-overview {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Styles for the Doomsday Tab */
#countdown {
    padding: 20px;
    background-color: #fff;
    box-shadow:0 2px 5px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
    max-width: 95%;
}

.countdown-header h2 {
    color: #23403B;
    margin-top: 0;
    text-align: center;
    margin-bottom: 10px;
}

.countdown-header p {
    color: #555;
    text-align: center;
    margin-bottom: 20px;
}

.financial-overview {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.asset-card,
.liability-card {
    flex: 1;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.asset-card h3,
.liability-card h3 {
    color: #555;
    margin-top: 0;
    margin-bottom: 10px;
}

.asset-card p,
.liability-card p {
    color: #23403B;
    font-size: 1.2em;
    font-weight: bold;
}

.overall-position {
    text-align: center;
    margin-bottom: 20px;
}

.overall-position h3 {
    color: #555;
    margin-top: 0;
    margin-bottom: 5px;
}

.overall-position p {
    font-size: 1.5em;
    font-weight: bold;
}

.overall-position p.positive {
    color: green;
}

.overall-position p.negative {
    color: red;
}

.time-until-no-money {
    margin-top: 20px;
}

.time-until-no-money h3 {
    color: #555;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
}

#time-until-no-money-table {
    margin: 0 auto;
    max-width: 80%;
}

#time-until-no-money-table th {
    text-align: center;
}

#time-until-no-money-table td {
    text-align: center;
}

.date-of-no-funds {
    text-align: center;
    margin-top: 20px;
}

.date-of-no-funds h3 {
    color: #555;
    margin-top: 0;
    margin-bottom: 5px;
}

.date-of-no-funds p {
    font-size: 1.2em;
    font-weight: bold;
    color: #d9534f;
}

.asset-breakdown,
.liability-breakdown {
    margin-top: 15px;
}

.asset-breakdown h4,
.liability-breakdown h4 {
    color: #555;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
}

.asset-breakdown table,
.liability-breakdown table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 5px;
}

.asset-breakdown th, .asset-breakdown td,
.liability-breakdown th, .liability-breakdown td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.asset-breakdown th,
.liability-breakdown th {
    background-color: #f9f9f9;
    font-weight: bold;
}

.net-time-until-no-money {
    margin-top: 20px;
}

.net-time-until-no-money h3 {
    color: #555;
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
}

#net-time-until-no-money-table {
    margin: 0 auto;
    max-width: 80%;
}

#net-time-until-no-money-table th {
    text-align: center;
}

#net-time-until-no-money-table td {
    text-align: center;
    display: block; /* Ensure block display for line breaks */
}

.overall-position.net-position {
    margin-bottom: 10px;
}

.time-until-no-money-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.time-until-no-money-container > div {
    flex: 1;
}

.net-date-of-no-funds {
    text-align: center;
    margin-top: 20px;
}

.net-date-of-no-funds h3 {
    color: #555;
    margin-top: 0;
    margin-bottom: 5px;
}

.net-date-of-no-funds p {
    font-size: 1.2em;
    font-weight: bold;
    color: #d9534f;
}
