body {
    font-family: Arial, sans-serif;
    margin: 25px;
    background-color: #808080;
    color: #333333;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}
body.high-contrast {
    background-color: #ffffff;
    color: #000000;
    border-color: #000000;
}
h1, h2 {
    color: #005566;
    font-weight: bold;
}
.section {
    margin-bottom: 30px;
    padding: 15px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
label {
    font-size: 20px;
    font-weight: bold;
    margin-right: 15px;
}
input, select, textarea {
    margin: 10px 0;
    padding: 12px;
    font-size: 18px;
    border: 1px solid #cccccc;
    border-radius: 4px;
    width: calc(100% - 26px);
    max-width: 320px;
    background-color: #ffffff;
}
input[type="checkbox"] {
    width: auto;
    vertical-align: middle;
}
button {
    padding: 12px 24px;
    font-size: 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 5px;
    transition: background-color 0.2s;
}
.out-button {
        background-color: #0000FF; /* Blue, adjust if needed */
        color: #FFFFFF; /* White text for high contrast */
        font-size: 16px; /* Larger font for mobile */
        font-weight: bold; /* Bold for clarity */
    }
button:hover {
    filter: brightness(1.1);
}
button:active {
    filter: brightness(0.9);
}
.in-button { background-color: #28a745; } /* IN */
.out-button { background-color: #007bff; } /* OUT */
.dnf-button { background-color: #dc3545; } /* DNF */
.note-button { background-color: #ffc107; } /* NOTE */
.change-distance-button { background-color: #17a2b8; } /* Change Distance */
.increment-button { background-color: #6c757d; } /* Increment */
.add-general-comment-button { background-color: #17a2b8; } /* Add General Comment */
.view-hide-bib-log-button { background-color: #17a2b8; } /* View/Hide Bib Log */
.export-csv-button { background-color: #28a745; } /* Export CSV */
.copy-winlink-button { background-color: #17a2b8; } /* Copy for Winlink */
.save-data-button { background-color: #28a745; } /* Save Data */
.load-data-button { background-color: #28a745; } /* Load Data */
.import-csv-button { background-color: #28a745; } /* Import CSV */
.import-bib-list-button { background-color: #28a745; } /* Import Bib List */
.view-hide-message-log-button { background-color: #17a2b8; } /* View/Hide Message Log */
#clearLogButton { background-color: #dc3545; } /* Clear Bib Log */
#updateButton { background-color: #17a2b8; } /* Update Entry */
#cancelEditButton { background-color: #6c757d; } /* Cancel Edit */
.edit-button { background-color: #6c757d; font-size: 16px; padding: 5px 10px; }
#distancePopup button { background-color: #17a2b8; margin: 5px; }
#resetNewestButton { background-color: #17a2b8; }
#syncButton { background-color: #17a2b8; }
table {
    border-collapse: collapse;
    width: auto; /* Let it expand based on content */
    max-width: 100%;
    margin-top: 10px;
    background-color: #ffffff;
    table-layout: auto; /* Change from fixed to auto for content-based sizing */
}
#bibTable, #messageLogTable {
    max-height: 400px;
}
th, td {
    border: 1px solid #cccccc;
    padding: 12px;
    text-align: left;
    font-size: 18px;
    min-width: 80px; /* Base min-width for alignment */
    white-space: nowrap; /* Prevent wrapping to keep data readable */
}
th {
    background-color: #f2f2f2;
    position: sticky;
    top: 0;
    font-weight: bold;
    cursor: pointer;
    z-index: 1;
}
th:hover {
    background-color: #e0e0e0;
}
tr:nth-child(even) {
    background-color: #f9f9f9;
}
#bibInfoTable {
    margin-top: 10px;
    max-width: 600px;
}
#logSearch {
    width: calc(100% - 26px);
    max-width: 400px;
    margin-bottom: 10px;
}
#distancePopup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #ffffff;
    padding: 20px;
    border: 1px solid #cccccc;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: none;
    z-index: 1000;
    max-width: 90%;
}
/* Scrollable table style - unified horizontal, vertical on body */
.bib-log-wrapper { /* Add this div in HTML around the table */
  overflow: auto; /* Handles both x and y scrolling */
  max-height: 730px; /* Your desktop vertical limit; adjust as needed */
}
#bibLogTable tbody {
  display: table-row-group; /* Reset to default (remove block) */
}
#bibLogTable tr {
  display: table-row; /* Reset to default (remove display: table) */
}

th, td {
    border: 1px solid #cccccc;
    padding: 12px;
    text-align: left;
    font-size: 18px;
    min-width: 80px; /* Base min-width for alignment */
    white-space: nowrap; /* Prevent wrapping to keep data readable */
}

/* Override for comment column (7th column, "C" for comments) - moved outside media query */
th:nth-child(7),
td:nth-child(7) {
    white-space: normal; /* Allow wrapping */
    word-wrap: break-word; /* Break long words if needed */
    max-width: 200px; /* Limit width to prevent over-expansion; adjust if too narrow/wide */
}

@media (max-width: 600px) {
  .bib-log-wrapper {
    overflow: auto;
  }
  #bibLogTable {
    width: 100%;
    table-layout: auto;
  }
  #bibLogTable tbody {
    display: table-row-group;
  }
  th, td {
    min-width: 80px; /* Slightly wider than 60px to reduce squashing */
    font-size: 14px; /* More readable than 10px, but still compact for mobile */
  }
}
