/* Download CSV button in edit work orders dialog */
#download-workorders-csv {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 4px;
    outline: none;
    display: flex;
    align-items: center;
}
#download-workorders-csv svg {
    display: block;
    transition: filter 0.2s;
}
#download-workorders-csv:hover svg {
    filter: brightness(1.2) drop-shadow(0 2px 4px #4caf5088);
}
body.dark #download-workorders-csv svg {
    filter: brightness(1.5);
}
body.dark, body.dark html {
    background: #181a1b !important;
}
/* Make Timesheet text lighter in dark theme */
body.dark #title, body.dark .title, body.dark h1#title {
    color: #eee !important;
    font-weight: 300 !important;
}
/* Make Timesheet text lighter in light theme */
#title, .title, h1#title {
    color: #888 !important;
    font-weight: 300 !important;
}
/* Gray out inactive work order options in dropdown */
#workorder-select option.inactive {
    color: #888 !important;
    background: #f5f5f5 !important;
    font-style: italic;
    opacity: 0.7;
}
body.dark #workorder-select option.inactive {
    color: #888 !important;
    background: #222 !important;
    font-style: italic;
    opacity: 0.7;
}
body.dark table, body.dark th, body.dark td {
    color: var(--fg) !important;
}
body.dark label {
    color: var(--fg) !important;
}
body.dark #workorder-modal input[type="checkbox"] {
    accent-color: #4caf50;
    background: #222 !important;
    border: 2px solid #4caf50 !important;
    width: 20px;
    height: 20px;
    outline: 1px solid #eee;
    box-shadow: 0 0 2px #4caf50;
}
body.dark #workorder-modal input[type="checkbox"]:checked {
    accent-color: #4caf50;
    background: #222 !important;
    border: 2px solid #4caf50 !important;
    box-shadow: 0 0 2px #4caf50;
}
body.dark #workorder-modal input[type="checkbox"]:checked::after {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    position: relative;
    left: 4px;
    top: 0px;
}
body.dark #workorder-modal td {
    color: #eee;
}
body.dark #workorder-modal .active-indicator {
    color: #4caf50 !important;
    font-weight: bold;
}
body.dark #workorder-modal .inactive-indicator {
    color: #f44336 !important;
    font-weight: bold;
}
body.dark #workorder-modal {
    background: #222 !important;
    color: #eee !important;
    border: 1px solid #444 !important;
    box-shadow: 0 2px 16px #000a;
}
body.dark #workorder-modal input,
body.dark #workorder-modal textarea,
body.dark #workorder-modal select {
    background: #222 !important;
    color: #eee !important;
    border: 1px solid #444 !important;
}
body.dark #workorder-modal button {
    background: #333 !important;
    color: #eee !important;
    border: 1px solid #555 !important;
    box-shadow: none !important;
}
/* Alternating row highlighting for table */
#entries-table tbody tr:nth-child(even) {
    background: #f2f6fa;
}
#entries-table tbody tr:nth-child(odd) {
    background: #fff;
}
body.dark #entries-table tbody tr:nth-child(even) {
    background: #23272b;
}
body.dark #entries-table tbody tr:nth-child(odd) {
    background: #181a1b;
}

/* Group summary row styling */
.group-header td {
    background: #e3f2fd !important;
    color: #222 !important;
    font-weight: bold;
    border-top: 2px solid #90caf9;
    border-bottom: 1px solid #90caf9;
}
body.dark .group-header td {
    background: #263238 !important;
    color: #e0e6ed !important;
    font-weight: bold;
    border-top: 2px solid #4fc3f7;
    border-bottom: 1px solid #4fc3f7;
    box-shadow: 0 2px 8px #000a;
}
/* Prevent wrapping in key table columns */
#entries-table th[data-col="user"],
#entries-table td[data-col="user"],
#entries-table th[data-col="work_order"],
#entries-table td[data-col="work_order"],
#entries-table th[data-col="activity_type"],
#entries-table td[data-col="activity_type"] {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Entry table action buttons - swapped theming for light/dark */
.edit-entry {
    background: #fff;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.delete-entry {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.edit-entry svg, .delete-entry svg {
    vertical-align: middle;
}
body.dark .edit-entry {
    background: var(--accent);
    color: #181a1b;
    border: 1px solid var(--accent);
}
body.dark .delete-entry {
    background: #23272b;
    color: var(--accent);
    border: 1px solid var(--accent);
}
/* Button theming for light and dark modes */
button, input[type="button"], input[type="submit"] {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
body.dark button, body.dark input[type="button"], body.dark input[type="submit"] {
    background: var(--accent);
    color: #181a1b;
    border: 1px solid var(--accent);
}
body.dark button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* Override for filter clear buttons to keep them minimal */
#filter-row button.clear-filter {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 16px;
    padding: 0 6px;
    border-radius: 50%;
    transition: background 0.2s;
}
#filter-row button.clear-filter:hover {
    background: var(--accent);
    color: #fff;
}
body.dark input,
body.dark select,
body.dark textarea {
    background-color: var(--input-bg) !important;
    color: var(--input-fg) !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
}
body.dark input[type="date"]::-webkit-input-placeholder,
body.dark input[type="text"]::-webkit-input-placeholder,
body.dark input[type="number"]::-webkit-input-placeholder {
    color: var(--input-fg) !important;
    opacity: 1 !important;
}
/* Force dark theme colors for all filter fields and top form fields */
body.dark #filter-row input[type="text"],
body.dark #filter-row input[type="date"],
body.dark #filter-row input,
body.dark #filter-row .filter-input,
body.dark #entry-form input[type="text"],
body.dark #entry-form input[type="date"],
body.dark #entry-form input[type="number"],
body.dark #entry-form select,
body.dark #entry-form textarea,
body.dark #user-select,
body.dark #workorder-select,
body.dark #activitytype-select,
body.dark #workorder-filter {
    background: var(--input-bg) !important;
    color: var(--input-fg) !important;
    border: 1px solid var(--border) !important;
}
body.dark input[type="text"],
body.dark input[type="date"],
body.dark input[type="number"],
body.dark select {
    /* Revert to default appearance */
}
body.dark textarea,
body.dark .filter-input {
    background: var(--input-bg) !important;
    color: var(--input-fg) !important;
    border: 1px solid var(--border) !important;
}
#user-select, #edit-users-btn, #workorder-select, #edit-workorders-btn, #workorder-filter, #desc-input, #filter-row input {
    background: var(--input-bg);
    color: var(--input-fg);
    border: 1px solid var(--border);
}
#edit-users-btn {
    min-width: 120px;
    width: auto;
    max-width: fit-content;
    box-sizing: border-box;
    display: inline-block;
    vertical-align: middle;
}
#desc-input {
    min-width: 180px;
    width: 100%;
    max-width: 100%;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1rem;
    padding: 6px 8px;
}
#download-db {
    background: none;
    border: none;
    padding: 0 4px;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: middle;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
}
#download-db svg {
    display: block;
}
#download-csv {
    background: none;
    border: none;
    padding: 0 4px;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: middle;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
}
#download-csv svg {
    display: block;
}
#workorder-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--table-bg);
    color: var(--fg);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    padding: 24px;
    z-index: 1002;
    min-width: 320px;
    max-width: 90vw;
}
body.dark #workorder-modal {
    background: #222 !important;
    color: #eee !important;
    border: 1px solid #444 !important;
    box-shadow: 0 2px 16px #000a;
}
body.dark #workorder-modal input,
body.dark #workorder-modal textarea,
body.dark #workorder-modal select {
    background: #222 !important;
    color: #eee !important;
    border: 1px solid #444 !important;
}
body.dark #workorder-modal button {
    background: #333 !important;
    color: #eee !important;
    border: 1px solid #555 !important;
    box-shadow: none !important;
}
body.dark #workorder-modal input[type="checkbox"] {
    accent-color: #4caf50;
    background: #222 !important;
    border: 1px solid #444 !important;
}
body.dark #workorder-modal td {
    color: #eee;
}
body.dark #workorder-modal .active-indicator {
    color: #4caf50 !important;
    font-weight: bold;
}
body.dark #workorder-modal .inactive-indicator {
    color: #f44336 !important;
    font-weight: bold;
}
#workorder-modal input,
#workorder-modal textarea,
#workorder-modal select {
    background: var(--input-bg);
    color: var(--input-fg);
    border: 1px solid var(--border);
}
#workorder-modal button {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--border);
    box-shadow: none;
}
#workorder-modal input[type="checkbox"] {
    accent-color: #4caf50;
}
#workorder-modal .active-indicator {
    color: #4caf50;
    font-weight: bold;
}
#workorder-modal .inactive-indicator {
    color: #f44336;
    font-weight: bold;
}
body {
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    margin: 0;
    padding: 0;
}
:root {
    --bg: #f8f9fa;
    --fg: #222;
    --modal-bg: rgba(0,0,0,0.4);
    --table-bg: #fff;
    --accent: #007bff;
    --input-bg: #fff;
    --input-fg: #222;
    --border: #ddd;
}
body.dark {
    --bg: #181a1b;
    --fg: #e0e6ed;
    --modal-bg: rgba(20,20,30,0.85);
    --table-bg: #23272b;
    --accent: #4fc3f7;
    --input-bg: #23272b;
    --input-fg: #e0e6ed;
    --border: #444b53;
}
#theme-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
}
main {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    background: var(--table-bg);
    border-radius: 0;
    box-shadow: none;
    padding: 16px 2vw;
    box-sizing: border-box;
}
#entry-form-section {
    margin-bottom: 32px;
}
#workorder-filter-container {
    display: flex;
    flex-direction: column;
}
#workorder-filter {
    margin-bottom: 4px;
    width: 100%;
    min-width: 220px;
    max-width: 350px;
    box-sizing: border-box;
}
#workorder-select {
    width: 100%;
    min-width: 220px;
    max-width: 350px;
}
#edit-workorders-btn {
    width: auto !important;
    min-width: fit-content;
    max-width: max-content;
    padding: 4px 12px;
    font-size: 1rem;
    box-sizing: border-box;
    display: inline-block;
}
#entries-table th {
    background: var(--table-bg);
    color: var(--fg);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
#entries-table th[data-col="id"] {
    width: 60px;
}
#entries-table th {
    cursor: pointer;
    user-select: none;
}
.sort-icon {
    margin-left: 4px;
    font-size: 12px;
}
#filter-row input {
    width: 100%;
    margin-right: 2px;
}
#filter-row input[data-col="date-from"], #filter-row input[data-col="date-to"] {
    width: 110px;
}
#filter-row button.clear-filter {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
}
#pagination-controls {
    margin: 16px 0;
    text-align: center;
}
#modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--modal-bg);
    z-index: 1000;
}
/* Main modal dialog */
#modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--table-bg);
    color: var(--fg);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    padding: 24px;
    z-index: 1001;
    min-width: 320px;
    max-width: 90vw;
}
/* User modal dialog (same style as main modal) */
#user-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--table-bg);
    color: var(--fg);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    padding: 24px;
    z-index: 1002;
    min-width: 320px;
    max-width: 90vw;
}
.hidden {
    display: none !important;
}
@media (max-width: 600px) {
    main {
        padding: 4px 1vw;
    }
    #entries-table th, #entries-table td {
        padding: 4px 2px;
    }
    #workorder-select {
        min-width: 120px;
    }
}
body.dark input,
body.dark select,
body.dark textarea {
    background-color: var(--input-bg) !important;
    color: var(--input-fg) !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
body.dark .filter-input {
    background-color: var(--input-bg) !important;
    color: var(--input-fg) !important;
    border: 1px solid var(--border) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
body.dark input[type="date"] {
    background: var(--input-bg) !important;
    color: var(--input-fg) !important;
    border: 1px solid var(--border) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
body.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.8;
}