/* Weekly timesheet and ready-to-invoice cards. */
@layer components {
  .page-header__subtitle {
    margin: var(--space-1) 0 0;
    color: var(--color-muted);
    font-size: var(--text-md);
  }

  .btn.btn--icon {
    width: var(--touch-target);
    padding: 0;
    font-size: var(--text-lg);
  }

  .timesheet {
    margin-bottom: var(--space-4);
  }

  .timesheet__table td,
  .timesheet__table th[scope="row"] {
    height: 60px;
  }

  .timesheet__table th[scope="row"] {
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--color-hairline);
    font-weight: 400;
    text-align: left;
  }

  .timesheet__code {
    min-width: 240px;
  }

  .timesheet__code-line {
    display: flex;
    align-items: center;
    gap: var(--space-2);
  }

  .timesheet__today abbr {
    color: var(--color-ink);
    font-weight: 700;
  }

  .timesheet__table abbr {
    text-decoration: none;
  }

  .table .timesheet__cell {
    position: relative;
    width: 96px;
    padding: var(--space-2);
    text-align: right;
  }

  .timesheet__form {
    position: relative;
  }

  .timesheet__input {
    width: 68px;
    height: 40px;
    padding: 0 var(--space-3);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--color-panel);
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
  }

  .timesheet__input:hover {
    border-color: var(--color-hairline);
  }

  .timesheet__input:focus-visible {
    border-color: var(--color-ink);
    outline: 2px solid var(--color-focus);
    outline-offset: 1px;
    background: var(--color-ground);
  }

  .timesheet__form[aria-busy="true"] .timesheet__input {
    color: var(--color-muted);
  }

  .timesheet__cell--invalid .timesheet__input {
    border-color: var(--color-danger);
  }

  .timesheet__error {
    position: absolute;
    z-index: 2;
    top: calc(100% - 6px);
    right: var(--space-2);
    width: max-content;
    max-width: 220px;
    margin: 0;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--color-danger);
    color: var(--color-on-ink);
    font-size: var(--text-xs);
    text-align: left;
  }

  .timesheet__billed,
  .timesheet__locked {
    display: inline-block;
    min-width: 68px;
    padding: 0 var(--space-3);
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
  }

  .timesheet__billed::after {
    content: " ✓";
  }

  /* Note: a small corner marker that opens a panel. */
  .timesheet__note {
    position: absolute;
    top: 0;
    right: 0;
  }

  .timesheet__note-toggle {
    display: block;
    width: 12px;
    height: 12px;
    list-style: none;
    cursor: pointer;
  }

  .timesheet__note-toggle::-webkit-details-marker {
    display: none;
  }

  .timesheet__note-toggle--set {
    background: linear-gradient(225deg, var(--color-ink) 50%, transparent 50%);
    border-top-right-radius: var(--radius-sm);
  }

  .timesheet__cell:hover .timesheet__note-toggle:not(.timesheet__note-toggle--set) {
    background: linear-gradient(225deg, var(--color-hairline) 50%, transparent 50%);
  }

  .timesheet__note-panel {
    position: absolute;
    z-index: 3;
    top: 16px;
    right: 0;
    width: 280px;
    padding: var(--space-3);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-md);
    background: var(--color-ground);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
    text-align: left;
  }

  .timesheet__note-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-2);
  }

  .timesheet__total {
    font-weight: 600;
  }

  .timesheet__table tbody tr:last-child th {
    border-bottom: 0;
  }

  .timesheet__totals td {
    border-top: 1px solid var(--color-hairline);
    border-bottom: 0;
    font-weight: 600;
  }

  .timesheet__add-input {
    width: 100%;
    max-width: 240px;
    height: 42px;
    padding: 0 var(--space-3);
    border: 1px dashed var(--color-hairline);
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 400;
  }

  /* Ready to invoice */
  .ready-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
    gap: var(--space-4);
    margin-top: var(--space-6);
  }

  .ready-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-lg);
  }

  .ready-card__who {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
  }

  .ready-card__name {
    font-weight: 600;
  }

  .ready-card__meta {
    color: var(--color-muted);
    font-size: var(--text-sm);
  }

  .ready-card__amount {
    font-size: var(--text-lg);
    font-weight: 600;
  }

  .btn[aria-disabled="true"] {
    color: var(--color-muted);
    cursor: not-allowed;
  }
}
