.timesheet-app {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--app-text, #1f2e40);
}

.timesheet-menubar-toolbar {
  display: flex;
  min-width: 0;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 0.5rem;
}

.timesheet-menubar-toolbar > .app-file-menu {
  flex: 0 0 auto;
  margin: 0;
}

.timesheet-toolbar {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: flex-start;
  gap: 0.4rem;
  overflow-x: auto;
}

.timesheet-toolbar .timesheet-icon-button {
  display: inline-flex;
  box-sizing: border-box;
  width: auto;
  min-width: 52px;
  min-height: 48px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.25rem 0.35rem;
}

.timesheet-icon-button svg {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.timesheet-icon-button::after {
  content: attr(data-label);
  max-width: 76px;
  font-size: 0.56rem;
  line-height: 1;
  overflow-wrap: anywhere;
  white-space: normal;
}

.timesheet-app h2,
.timesheet-app h3,
.timesheet-app p {
  margin-top: 0;
}

.timesheet-disclaimer {
  padding: 0.7rem 0.85rem;
  border: 1px solid #dfc98f;
  border-left: 4px solid #c08a26;
  border-radius: 0.55rem;
  background: #fff8e8;
  color: #59451c;
  font-size: 0.82rem;
  line-height: 1.5;
}

.timesheet-disclaimer strong {
  color: #463411;
}

.timesheet-status {
  min-height: 1.3em;
  margin-bottom: 0;
  color: var(--app-muted, #54708d);
  font-size: 0.82rem;
}

.timesheet-app .persistence-note {
  margin: 0;
}

.timesheet-panels {
  display: flex;
  min-height: auto;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 0.75rem;
  overflow: visible;
}

.timesheet-panel,
.timesheet-history {
  box-sizing: border-box;
  display: flex;
  min-width: 0;
  min-height: auto;
  flex: 1 0 0;
  flex-direction: column;
  overflow: visible;
  padding: 0.85rem;
  border: 1px solid var(--app-border, #d3deea);
  border-radius: 0.75rem;
  background: var(--app-panel-surface, #f6f9fc);
  color: var(--app-text, #1f2e40);
}

.timesheet-panel:not([open]),
.timesheet-history:not([open]) {
  flex: 0 0 auto;
}

.timesheet-panel > summary,
.timesheet-history > summary {
  display: flex;
  min-height: 1.5rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
  list-style: none;
}

.timesheet-panel > summary::-webkit-details-marker,
.timesheet-history > summary::-webkit-details-marker {
  display: none;
}

.timesheet-panel > summary::after,
.timesheet-history > summary::after {
  color: var(--app-muted, #55718e);
  content: '+';
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
}

.timesheet-panel[open] > summary::after,
.timesheet-history[open] > summary::after {
  content: '-';
}

.timesheet-panel > summary:focus-visible,
.timesheet-history > summary:focus-visible {
  outline: 2px solid #2e8dc2;
  outline-offset: 2px;
}

.timesheet-panel-body,
.timesheet-history-body {
  min-height: auto;
  flex: 1 0 auto;
  overflow: visible;
  padding-top: 0.65rem;
}

.timesheet-history-body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  overflow: visible;
}

.timesheet-panel h2,
.timesheet-history h2 {
  margin: 0;
  color: var(--app-text, #263d59);
  font-size: 1rem;
}

.timesheet-form {
  display: grid;
  gap: 0.6rem;
}

.timesheet-form label,
.timesheet-filters label,
.timesheet-search-label {
  display: grid;
  min-width: 0;
  gap: 0.25rem;
  color: var(--app-muted, #42566f);
  font-size: 0.76rem;
  font-weight: 700;
}

.timesheet-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.timesheet-form input:not([type="hidden"]),
.timesheet-form select,
.timesheet-form textarea,
.timesheet-filters select,
.timesheet-search-label input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--app-border, #c5d1df);
  border-radius: 0.45rem;
  background: var(--app-control-surface, #fff);
  color: var(--app-text, #1f2e40);
  font: inherit;
  font-size: 0.84rem;
}

.timesheet-form textarea {
  min-height: 4rem;
  resize: vertical;
}

.timesheet-form input:focus-visible,
.timesheet-form select:focus-visible,
.timesheet-form textarea:focus-visible,
.timesheet-filters select:focus-visible,
.timesheet-search-label input:focus-visible {
  outline: 2px solid #2e8dc2;
  outline-offset: 1px;
}

.timesheet-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.timesheet-form-actions [hidden] {
  display: none;
}

.timesheet-project-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.timesheet-search-label {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.7rem;
  font-size: 0.76rem;
  font-weight: 700;
}

.timesheet-search-label input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 2.35rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  font: inherit;
  font-size: 0.84rem;
}

.timesheet-alphabet {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.55rem;
}

.timesheet-letter-button {
  min-width: 1.8rem;
  min-height: 1.8rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--app-border, #c5d1df);
  border-radius: 0.35rem;
  background: var(--app-control-surface, #fff);
  color: var(--app-text, #1f2e40);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.timesheet-letter-button[aria-pressed="true"] {
  border-color: var(--app-accent, #3976c5);
  background: var(--app-accent, #3976c5);
  color: var(--app-action-text, #fff);
}

.timesheet-letter-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.timesheet-project-card {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--app-border, #d4deea);
  border-radius: 0.55rem;
  background: var(--app-content-surface, #fff);
  color: var(--app-text, #1f2e40);
}

.timesheet-project-card > div:not(.timesheet-project-actions) {
  display: grid;
  min-width: 0;
  gap: 0.15rem;
}

.timesheet-project-card strong {
  overflow-wrap: anywhere;
}

.timesheet-project-card p {
  margin: 0;
  color: var(--app-muted, #61738a);
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.timesheet-project-number,
.timesheet-row-job-number {
  color: var(--app-muted, #687b91);
  font-size: 0.72rem;
}

.timesheet-project-edit {
  flex: 0 0 auto;
  min-height: 2rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.76rem;
}

.timesheet-project-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.55rem;
}

.timesheet-project-added-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--app-muted, #42566f);
  font-size: 0.7rem;
  white-space: nowrap;
}

.timesheet-project-added-label input {
  accent-color: var(--app-accent, #3976c5);
}

.timesheet-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 0.65rem;
}

.timesheet-pagination[hidden] {
  display: none;
}

.timesheet-page-button {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
}

.timesheet-page-button[aria-current="page"] {
  border-color: var(--app-accent, #3976c5);
  background: var(--app-accent, #3976c5);
  color: var(--app-action-text, #fff);
}

.timesheet-page-ellipsis,
.timesheet-pagination-summary {
  color: var(--app-muted, #61738a);
  font-size: 0.72rem;
}

.timesheet-pagination-summary {
  margin-left: 0.2rem;
}

.timesheet-empty {
  margin: 0;
  padding: 0.75rem;
  border: 1px dashed var(--app-border, #bdcad9);
  border-radius: 0.55rem;
  color: var(--app-muted, #61738a);
  font-size: 0.82rem;
  text-align: center;
}

.timesheet-history {
  min-height: 0;
}

.timesheet-history-header {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto 1rem;
  align-items: center;
}

.timesheet-history-header h2 {
  margin: 0;
}

.timesheet-history-header output {
  color: var(--app-accent, #2874a4);
  font-size: 0.95rem;
  font-weight: 800;
  white-space: normal;
  text-align: right;
}

.timesheet-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 0.55rem;
}

.timesheet-entry-groups {
  display: grid;
  min-height: auto;
  flex: 1 0 auto;
  gap: 0.65rem;
  align-content: start;
  overflow: visible;
}

.timesheet-week-group {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--app-border, #d1dce8);
  border-radius: 0.6rem;
  background: var(--app-content-surface, #fff);
  color: var(--app-text, #1f2e40);
}

.timesheet-week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
  background: var(--app-panel-surface, #eaf1f8);
  gap: 0.6rem;
}

.timesheet-week-group h3 {
  margin: 0;
  color: var(--app-text, #284866);
  font-size: 0.84rem;
}

.timesheet-week-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.timesheet-week-total {
  color: var(--app-muted, #365675);
  font-size: 0.76rem;
  font-weight: 750;
  text-align: right;
  white-space: nowrap;
}

.timesheet-view-week {
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.74rem;
  white-space: nowrap;
}

.timesheet-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.timesheet-entry-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  color: var(--app-text, #1f2e40);
}

.timesheet-entry-table th,
.timesheet-entry-table td {
  padding: 0.5rem 0.6rem;
  border-top: 1px solid var(--app-border, #e0e7ef);
  text-align: left;
  vertical-align: top;
}

.timesheet-entry-table th {
  color: var(--app-muted, #53677e);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.timesheet-day-group-even td {
  background-color: color-mix(in srgb, var(--app-content-surface, #fff) 88%, var(--app-panel-surface, #edf3fa));
}

.timesheet-day-group-odd td {
  background-color: var(--app-panel-surface, #edf3fa);
}

.timesheet-entry-table .timesheet-day-heading th {
  background-color: var(--app-panel-surface, #edf3fa);
  color: var(--app-text, #2d4863);
  font-size: 0.78rem;
  letter-spacing: normal;
  text-transform: none;
}

.timesheet-entry-table .timesheet-day-total th,
.timesheet-entry-table .timesheet-day-total td {
  background-color: var(--app-panel-surface, #edf3fa);
  color: var(--app-text, #2d4863);
  font-weight: 750;
}

.timesheet-entry-table .timesheet-day-total th {
  font-size: 0.76rem;
  letter-spacing: normal;
  text-transform: none;
}

.timesheet-entry-table td strong,
.timesheet-row-job-number {
  display: block;
}

.timesheet-hours-cell {
  font-weight: 750;
  white-space: nowrap;
}

.timesheet-notes-cell {
  min-width: 10rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.timesheet-row-actions {
  display: flex;
  gap: 0.35rem;
  white-space: nowrap;
}

.timesheet-row-actions .btn {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.74rem;
}

.timesheet-app .timesheet-form-actions .btn,
.timesheet-app .timesheet-project-actions .btn {
  width: auto;
  min-width: 0;
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
}

.timesheet-app #timesheetEntrySave {
  min-width: 9.5rem;
}

.timesheet-app #timesheetJobSave,
.timesheet-app #timesheetJobCancel {
  min-width: 8.5rem;
}

.timesheet-app .timesheet-row-actions .btn {
  min-width: 0;
  padding-inline: 0.35rem;
}

.timesheet-app .timesheet-project-actions .timesheet-project-edit,
.timesheet-app .timesheet-project-actions .timesheet-project-delete {
  min-width: 0;
  padding-inline: 0.45rem;
}

.timesheet-confirm-dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--app-border, #b9c9dc);
  border-radius: 0.8rem;
  background: var(--app-window-surface, #f7faff);
  color: var(--app-text, #1d2d43);
  box-shadow: 0 1.25rem 3.5rem rgba(0, 0, 0, 0.36);
}

.timesheet-confirm-dialog::backdrop {
  background: rgba(3, 10, 20, 0.62);
  backdrop-filter: blur(2px);
}

.timesheet-confirm-dialog h2 {
  margin: 0 0 0.55rem;
  color: var(--app-text, #1d2d43);
  font-size: 1.05rem;
}

.timesheet-confirm-dialog p {
  margin: 0;
  color: var(--app-muted, #52657e);
  overflow-wrap: anywhere;
}

.timesheet-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.timesheet-confirm-actions .btn {
  width: auto;
  min-width: 6rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
}

.desktop.dark-theme .timesheet-disclaimer {
  border-color: #705b32;
  border-left-color: #dfb353;
  background: #302817;
  color: #f1dfb7;
}

.desktop.dark-theme .timesheet-disclaimer strong {
  color: #fff0cb;
}

@media (max-width: 640px) {
  .timesheet-week-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .timesheet-week-summary {
    width: 100%;
    justify-content: space-between;
  }

  .timesheet-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timesheet-entry-table {
    min-width: 680px;
  }

  .timesheet-history-header {
    grid-template-columns: minmax(0, 1fr) 1rem;
    row-gap: 0.35rem;
  }

  .timesheet-history-header h2 {
    grid-column: 1;
  }

  .timesheet-history-header output {
    grid-row: 2;
    grid-column: 1 / -1;
    white-space: normal;
  }

  .timesheet-history-header::after {
    grid-row: 1;
    grid-column: 2;
  }

  .timesheet-project-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .timesheet-project-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 420px) {
  .timesheet-form-row {
    grid-template-columns: 1fr;
  }

  .timesheet-panel,
  .timesheet-history {
    padding: 0.65rem;
  }
}
