body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    background-color: #f8f9fa;
    color: #343a40;
    margin: 0;
    padding: 20px;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    background-color: #fff;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #dee2e6;
    display: none; /* Initially hidden for login */
}

h1, h2 {
    color: #212529;
    border-bottom: 3px solid #0d6efd;
    padding-bottom: 10px;
    margin-bottom: 25px;
}

h1 {
    text-align: center;
    font-size: 2.3em;
    font-weight: 700;
    border-bottom: none;
    color: #0d6efd;
}

h2 {
    font-size: 1.7em;
    font-weight: 700;
}

p {
    text-align: center;
    color: #6c757d;
    margin-bottom: 30px;
}

#settings-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 20px 25px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 15px;
}

.settings-group {
    display: flex;
    gap: 20px;
    align-items: center;
}

.setting-item label {
    font-weight: 500;
    margin-right: 8px;
    color: #495057;
}

#fiscal-month-start {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #ced4da;
    font-size: 1em;
    background-color: #fff;
}

#fiscal-month-start:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.data-management {
    display: flex;
    gap: 10px;
    align-items: center;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #fff;
    min-width: 220px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.1);
    z-index: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.dropdown-content.show {
    display: block;
}

.dropdown-content .dropdown-item {
    color: #212529;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
    transition: background-color 0.2s ease-in-out;
}

.dropdown-content .dropdown-item:hover {
    background-color: #f1f3f5;
}

.dropdown-divider {
    height: 1px;
    margin: 8px 0;
    overflow: hidden;
    background-color: #e9ecef;
}

#form-container, #summary-container, #ledger-container, #usage-guide-container {
    margin-bottom: 40px;
    padding: 25px 30px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #ffffff;
}

#fee-type-group {
    grid-column: span 1;
    min-width: 150px;
}

#deal-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px 25px;
    align-items: end;
}

.bank-details-group {
    grid-column: 1 / -1; /* Span full width */
    display: grid;
    grid-template-columns: repeat(3, 1fr) auto;
    gap: 20px 25px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    align-items: end;
}

.form-group.deal-details, .form-group.bank-details {
    grid-column: span 1;
}

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

label {
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 0.95em;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input:focus,
select:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-actions {
    display: flex;
    flex-direction: row-reverse;
    gap: 10px;
}

button, .btn {
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.1s ease;
    height: fit-content;
}

button:active, .btn:active {
    transform: translateY(1px);
}

button[type="submit"] {
    background-color: #ffc107;
    color: #000;
    width: 100%;
    white-space: nowrap;
}

button[type="submit"]:hover {
    background-color: #d39e00;
}

.server-update-container {
    text-align: center;
    margin: 30px 0;
}

.update-btn {
    background-color: #dc3545;
    color: white;
    font-weight: 700;
    padding: 15px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    border: none; /* Ensure no border is applied */
}

.update-btn:hover {
    background-color: #bb2d3b;
}

.secondary-btn {
    background-color: #6c757d;
    color: white;
    text-align: center;
}

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

.filters-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#search-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 1em;
    min-width: 200px;
}

.filter-buttons {
    display: flex;
    gap: 5px;
    background-color: #e9ecef;
    border-radius: 5px;
    padding: 5px;
}

.filter-btn {
    padding: 8px 15px;
    border: none;
    background-color: transparent;
    cursor: pointer;
    border-radius: 5px;
    font-size: 0.9em;
    color: #495057;
    transition: background-color 0.3s, color 0.3s;
    font-weight: 500;
}

.filter-btn.active, .filter-btn:hover {
    background-color: #0d6efd;
    color: white;
}

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

.header-with-button h2 {
    margin-bottom: 0;
}

.upload-label {
    display: block;
    width: 100%;
    cursor: pointer;
}

#year-tabs-container {
    display: flex;
    gap: 5px;
    margin-bottom: -1px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.year-tab {
    padding: 10px 20px;
    background-color: #e9ecef;
    border: 1px solid #dee2e6;
    border-bottom: none;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    font-size: 1em;
    color: #495057;
    transition: background-color 0.3s, color 0.3s;
    font-weight: 500;
}

.year-tab.active {
    background-color: #fff;
    color: #0d6efd;
    font-weight: 700;
    border-top: 3px solid #0d6efd;
    border-bottom: 1px solid #fff;
}

#summary-container {
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    padding: 25px 30px;
    border-radius: 8px;
}

#monthly-summary table {
    width: 100%;
    margin-top: 0;
}

#monthly-summary th, #monthly-summary td {
    text-align: right;
    padding: 12px;
}

#monthly-summary th {
    background-color: #fff;
    color: #212529;
}

#monthly-summary th:first-child, #monthly-summary td:first-child {
    text-align: center;
    font-weight: bold;
}

#monthly-summary .total-row {
    font-weight: bold;
    background-color: #e9ecef;
}

#monthly-summary .total-row td {
    border-top: 2px solid #adb5bd;
    color: #212529;
}

#monthly-summary th:last-child,
#monthly-summary td:last-child {
    font-weight: bold;
    color: #0d6efd;
    background-color: #e9ecef;
}

#monthly-summary .col-chukairyo { background-color: rgba(231, 245, 255, 0.6); }
#monthly-summary .col-kokokuryo { background-color: rgba(255, 248, 225, 0.6); }
#monthly-summary .col-sonota { background-color: rgba(243, 229, 245, 0.6); }

#monthly-summary th.col-total, #monthly-summary td.col-total {
    font-weight: bold;
    color: #0d6efd;
    background-color: #e9ecef;
    font-size: 1.1em;
}

.bank-info-box {
    text-align: left;
    margin: 25px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.bank-info-box p {
    margin: 10px 0;
    font-size: 1.1em;
    color: #343a40;
    text-align: left;
}

.bank-info-box strong {
    display: inline-block;
    width: 90px;
    color: #495057;
    font-weight: 500;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

th {
    background-color: #343a40;
    color: #fff;
    font-weight: 500;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    transition: background-color 0.2s ease-in-out;
}

tbody tr.type-chukairyo { background-color: #e7f5ff; }
tbody tr.type-chukairyo:nth-child(even) { background-color: #f0f8ff; }

tbody tr.type-kokokuryo { background-color: #fff8e1; }
tbody tr.type-kokokuryo:nth-child(even) { background-color: #fffbec; }

tbody tr.type-sonota { background-color: #f3e5f5; }
tbody tr.type-sonota:nth-child(even) { background-color: #f9f0fa; }

tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

tbody tr:hover {
    background-color: #e9ecef;
}

.clickable-date {
    cursor: pointer;
    text-decoration: underline;
    color: #0d6efd;
    font-weight: 500;
}

.clickable-date:hover {
    color: #0b5ed7;
}

td:nth-child(5) {
    text-align: right;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
}

th:nth-child(5) {
    text-align: right;
}

.action-btns {
    display: flex;
    gap: 8px;
}

.edit-btn, .duplicate-btn, .delete-btn {
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
    font-size: 0.85em;
    line-height: 1.5;
}

.edit-btn:active, .duplicate-btn:active, .delete-btn:active {
    transform: translateY(1px);
}

.edit-btn {
    background-color: #198754;
}

.edit-btn:hover {
    background-color: #157347;
}

.duplicate-btn {
    background-color: #ffc107;
    color: #000;
}

.duplicate-btn:hover {
    background-color: #d39e00;
}

.delete-btn {
    background-color: #dc3545;
}

.delete-btn:hover {
    background-color: #bb2d3b;
}

#usage-guide-container {
    margin-top: 40px;
    padding: 25px 30px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
}

#usage-guide-container h3 {
    font-size: 1.25em;
    color: #343a40;
    border-bottom: none;
    padding-bottom: 0;
    margin: 0;
    display: flex;
    align-items: center;
    width: 100%;
}

.guide-icon {
    margin-right: 15px;
    font-size: 1.3em;
    color: #0d6efd;
}

.guide-section {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 15px;
    background-color: #fff;
    transition: box-shadow 0.3s ease;
    overflow: hidden;
}

.guide-section[open] {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border-color: #adb5bd;
}

.guide-section summary {
    padding: 15px 20px;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.guide-section summary::-webkit-details-marker {
    display: none;
}

.guide-section summary::after {
    content: '\25BC';
    font-size: 0.8em;
    color: #0d6efd;
    transform: rotate(-90deg);
    transition: transform 0.3s ease;
}

.guide-section[open] summary::after {
    transform: rotate(0deg);
}

.guide-content {
    padding: 0 25px 25px 25px;
    border-top: 1px solid #e9ecef;
    margin-top: 15px;
    padding-top: 20px;
}

#usage-guide-container p,
#usage-guide-container li {
    line-height: 1.8;
    color: #495057;
}

#usage-guide-container h4 {
    font-size: 1.1em;
    color: #212529;
    margin: 15px 0 5px;
    display: flex;
    align-items: center;
}

.sub-icon {
    margin-right: 10px;
    font-size: 1.1em;
}

.warning-text {
    color: #dc3545;
}

#usage-guide-container ol, #usage-guide-container ul {
    padding-left: 25px;
    margin: 0 0 1em 0;
}

#usage-guide-container li {
    margin-bottom: 15px;
}

#usage-guide-container li p {
    margin: 5px 0 0 0;
    text-align: left;
}

#usage-guide-container strong {
    color: #212529;
    font-weight: 500;
}

.guide-download-link {
    display: inline-block;
    background-color: #198754;
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    margin-top: 10px;
    transition: background-color 0.2s ease-in-out;
}

.guide-download-link:hover {
    background-color: #157347;
    text-decoration: none;
}

#usage-guide-container a {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
}

#usage-guide-container a:hover {
    text-decoration: underline;
}

.highlight {
    background-color: #fff3cd;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    color: #664d03;
}

.guide-download-link:hover {
    background-color: #157347;
    text-decoration: none;
}

#usage-guide-container a {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
}

#usage-guide-container a:hover {
    text-decoration: underline;
}

/* Loading Indicator Styles */
#loading-indicator {
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Login Screen Styles */
.overlay-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(33, 37, 41, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.login-box {
    background: #fff;
    padding: 35px 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid #dee2e6;
}

.login-box h2 {
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: none;
    color: #0d6efd;
    font-size: 1.8em;
}

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

.login-box label {
    font-size: 0.9em;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    font-size: 1em;
}

.login-box .form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    justify-content: center;
}

.login-box .form-actions button {
    flex-grow: 1;
}

.login-box p {
    color: #6c757d;
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 20px;
    text-align: left;
}

.error-message {
    color: #dc3545;
    font-size: 0.9em;
    margin-top: 15px;
    height: 1.2em;
    text-align: center;
}

/* Toast Notification Styles */
#toast-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #28a745; /* Green for success */
    color: #fff;
    padding: 12px 25px;
    border-radius: 8px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s, visibility 0.5s, bottom 0.5s ease-in-out;
    font-size: 1em;
    font-weight: 500;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    text-align: center;
}

#toast-notification.show {
    bottom: 40px;
    opacity: 1;
    visibility: visible;
}

#toast-notification.error {
    background-color: #dc3545; /* Red for error */
}