/* ============================================================
   Timesheet Grid Styles — Spreadsheet-style layout
   ============================================================ */

/* ── Page layout ─────────────────────────────────────────────── */
.timesheet-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.ts-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 10px;
  border-bottom: 2px solid #ddd;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ts-toolbar-left  { display: flex; align-items: center; gap: 6px; }
.ts-toolbar-center{ flex: 1; text-align: center; }
.ts-toolbar-right { display: flex; align-items: center; gap: 6px; }
.sel-month, .sel-year {
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 5px 6px;
  font-size: 13px;
  cursor: pointer;
}
.month-display { display: flex; gap: 4px; }
.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: #fff;
  border: 1px solid #ccd2d8;
  border-radius: 6px;
  color: #546e7a;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-nav:hover {
  background: #e8edf2;
  border-color: #9eaab4;
  color: #263238;
}
.viewing-as { font-size: 12px; color: #666; margin-left: 8px; }

/* Categories button injected into the mobile topbar — only present on timesheet page */
.mobile-ts-cats-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  color: var(--color-nav-text, #fff);
  cursor: pointer;
  border-radius: var(--radius, 6px);
  flex-shrink: 0;
  touch-action: manipulation;
}
.mobile-ts-cats-btn:hover { background: var(--color-nav-hover); }

/* ── Undo / Redo buttons ─────────────────────────────────────── */
.undo-redo-group {
  display: flex;
  gap: 3px;
  margin-left: 6px;
  padding-left: 10px;
  border-left: 1px solid #ccd2d8;
}
.btn-undo-redo:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Viewing-as banner ───────────────────────────────────────── */
.ts-viewing-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #e8f3fe;
  border-bottom: 2px solid #90caf9;
  padding: 9px 18px;
  font-size: 13px;
  color: #0d47a1;
}
.ts-viewing-banner svg { flex-shrink: 0; }
.ts-viewing-back {
  margin-left: auto;
  font-size: 12px;
  color: #0078d4;
  text-decoration: none;
  white-space: nowrap;
}
.ts-viewing-back:hover { text-decoration: underline; }
[data-theme="dark"] .ts-viewing-banner {
  background: #0d2137;
  border-bottom-color: #1e5c8a;
  color: #90caf9;
}
[data-theme="dark"] .ts-viewing-back { color: #60b4f8; }

/* ── Status badge in toolbar ─────────────────────────────────── */
.ts-status-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
/* colors reuse status-* from main.css */

/* ── Loading ─────────────────────────────────────────────────── */
.ts-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 30px;
  color: #888;
  font-size: 14px;
}

/* ── Main scrollable wrapper ─────────────────────────────────── */
.ts-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  gap: 14px;
  padding-top: 10px;
}
.ts-scroll-outer {
  flex: 1;
  overflow: auto;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* ── Grid table ──────────────────────────────────────────────── */
.ts-grid {
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 100%;
  white-space: nowrap;
}
/* Hide the group-header row (Date / Time / Work Categories / etc.) */
.ts-grid thead tr.ts-header-groups { display: none; }

/* ── Frozen first columns ────────────────────────────────────── */
.ts-grid thead th {
  position: sticky;
  top: 0;
  background: #e8edf2;
  z-index: 10;
  border-bottom: 2px solid #b0bec5;
}
.ts-grid tfoot td {
  position: sticky;
  bottom: 28px;
  background: #ecf0f4;
  z-index: 10;
  border-top: 2px solid #b0bec5;
}
.ts-grid tfoot tr.ts-match-status td {
  bottom: 0;
  border-top: none !important;
}
.ts-grid thead tr:first-child th,
.ts-grid thead tr:last-child th {
  top: 0; /* groups row is hidden so cols row sits flush at top */
}

/* ── Header rows ─────────────────────────────────────────────── */
.ts-header-groups th,
.ts-header-cols th {
  padding: 5px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  border-right: 1px solid #c0cad4;
  color: #37474f;
}
.col-frozen {
  position: sticky !important;
  left: 0;
  z-index: 20 !important;
  background: #e8edf2 !important;
}
/* Day column must sit right of Date column */
.ts-grid thead th.col-day,
.ts-grid tfoot td.col-day { left: 38px; }
.col-date  { min-width: 38px; }
.col-day   { min-width: 32px; text-align: center !important; }
/* Visual separator after frozen area */
.ts-grid td.col-day,
.ts-grid th.col-day {
  border-right: 2px solid #b0bec5 !important;
}
.col-in, .col-out { min-width: 80px; }
.col-away { min-width: 65px; }
.col-total, .col-ot, .col-banked { min-width: 65px; }
.col-notes { min-width: 120px; }

/* Group header colors */
.col-date-hdr  { background: #e3e8f0 !important; }
.col-clock-hdr { background: #e8f0e3 !important; }
.col-leave-hdr { background: #f0e8e3 !important; }
.col-totals-hdr{ background: #e3f0e8 !important; }
.col-notes-hdr { background: #f0f0e3 !important; }

/* ── Body rows ───────────────────────────────────────────────── */
.ts-grid tbody tr { border-bottom: 1px solid #e0e0e0; }
.ts-grid tbody tr:hover { background: #f5f9ff !important; }

/* Weekend rows */
.ts-grid tbody tr.is-weekend td { background: #efefef !important; }
.ts-grid tbody tr.is-weekend .col-date { color: #999; }
.ts-grid tbody tr.is-weekend .col-day { color: #c66; font-weight: 600; }

/* Today highlight */
.ts-grid tbody tr.is-today { background: #fffde7 !important; }
.ts-grid tbody tr.is-today .col-date { font-weight: 700; color: #0078d4; background-color: khaki; }

/* Extra space after the last data row so sticky tfoot doesn't cover it */
.ts-grid tbody tr:last-child td { padding-bottom: 1px; }

/* ── Cells ───────────────────────────────────────────────────── */
.ts-grid td {
  padding: 2px 3px;
  border-right: 1px solid #e8e8e8;
  vertical-align: middle;
  text-align: center;
}
.ts-grid td.col-date {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #546e7a;
  background: #f5f7fa;
  position: sticky;
  left: 0;
  z-index: 5;
}
.ts-grid td.col-day {
  text-align: center;
  font-size: 11px;
  color: #78909c;
  background: #f5f7fa;
  position: sticky;
  left: 38px;
  z-index: 5;
}

/* ── Row action buttons (copy / clear) — desktop, revealed on row hover ── */
.btn-copy-day,
.btn-clear-day {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  padding: 0;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, background .15s;
  z-index: 2;
  line-height: 1;
}
.btn-copy-day  { right: 1px;  background: rgba(0,120,212,.15); color: #0078d4; }
.btn-clear-day { left: 1px;   background: rgba(198,40,40,.12); color: #c62828; }
.ts-grid tbody tr:hover .btn-copy-day,
.ts-grid tbody tr:hover .btn-clear-day { opacity: 1; pointer-events: auto; }
.btn-copy-day:hover  { background: rgba(0,120,212,.3); }
.btn-clear-day:hover { background: rgba(198,40,40,.25); }

/* ── Row action buttons — mobile, always visible on card ────── */
.ts-day-copy-btn,
.ts-day-clear-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0 6px 0 0;
  transition: background .15s, color .15s, border-color .15s;
}
.ts-day-copy-btn  { color: var(--color-text-mute, #666); }
.ts-day-clear-btn { color: #c62828; border-color: rgba(198,40,40,.3); }
.ts-day-copy-btn:active {
  background: rgba(0,120,212,.1);
  color: var(--color-primary, #0078d4);
  border-color: var(--color-primary, #0078d4);
}
.ts-day-clear-btn:active {
  background: rgba(198,40,40,.1);
  border-color: #c62828;
}

/* ── Editable inputs inside cells ────────────────────────────── */
.ts-grid input[type="text"],
.ts-grid input[type="number"],
.ts-grid input[type="time"] {
  border: 1px solid transparent;
  background: transparent;
  padding: 3px 5px;
  font-size: 12.5px;
  font-family: inherit;
  color: inherit;
  width: 100%;
  text-align: center;
  transition: border-color .1s, background .1s;
}
.ts-grid input[type="number"] { text-align: center; }
.ts-grid input:focus {
  outline: none;
  border-color: #0078d4;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0,120,212,.15);
  border-radius: 2px;
  position: relative;
  z-index: 1;
}
.ts-grid input[type="text"].notes-input { text-align: left; width: 180px; }
.ts-grid input[type="time"] { width: 98px; }

/* Read-only cells */
.ts-grid td.cell-readonly input,
.ts-grid td.cell-calc { background: #f5f7fa; color: #546e7a; }
.ts-grid td.cell-calc { text-align: center; font-size: 12px; font-weight: 600; }

/* Category hour cells */
.ts-grid td.cell-category { min-width: 70px; }
.ts-grid td.cell-category input { color: #1a237e; }

/* Holiday rows */
.ts-grid tbody tr.is-holiday td { background: #fff8e1 !important; }
.ts-grid tbody tr.is-holiday .col-date { color: #b45309; font-weight: 700; }

/* Holiday cell */
.ts-grid td.cell-holiday {
  min-width: 65px;
  background: #fff3e0;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #e65100;
}

/* Leave cells */
.ts-grid td.cell-leave { min-width: 60px; background: #fff8f5; }
.ts-grid td.cell-leave input { color: #bf360c; }

/* Clocked hours cell */
.ts-grid td.cell-clocked { background: #f0f4f8; min-width: 70px; text-align: center; }
.ts-grid td.cell-clocked .cell-val { color: #455a64; font-weight: 600; }
.col-clocked { min-width: 70px; }

/* Mismatch highlight on footer totals */
.ts-grid tfoot td.hours-mismatch { background: #fce4ec !important; color: #c62828 !important; }

/* Per-row mismatch highlight on clocked + total cells */
.ts-grid tbody td.cell-clocked.row-hours-mismatch,
.ts-grid tbody td.cell-total-h.row-hours-mismatch { background: #fce4ec !important; }
.ts-grid tbody td.cell-clocked.row-hours-mismatch .cell-val,
.ts-grid tbody td.cell-total-h.row-hours-mismatch .cell-val { color: #c62828 !important; }

/* Match status row */
.ts-match-cell {
  text-align: left !important;
  font-size: 12px;
  font-weight: 600;
  height: 28px;
  line-height: 18px;
  padding: 5px 12px !important;
  box-sizing: border-box;
  border-top: none !important;
}
.ts-match-good { background: #e8f5e9 !important; color: #2e7d32; }
.ts-match-bad  { background: #fce4ec !important; color: #c62828; }


/* OT cell */
.ts-grid td.cell-ot { background: #fff3e0; }
.ts-grid td.cell-ot .cell-val { color: #e65100; font-weight: 600; }

/* Away cell */
.ts-grid td.cell-away { text-align: center; }
.ts-grid td.cell-away .cell-val { color: #7b5ea7; font-weight: 600; }

/* Banked cell */
.ts-grid td.cell-banked { text-align: center; }
.ts-grid td.cell-banked .cell-val { color: #f57f17; font-weight: 600; }

/* Leave cell */
.ts-grid td.cell-leave { text-align: center; }

/* Total cell */
.ts-grid td.cell-total-h { background: #e8f5e9; text-align: center; }
.ts-grid td.cell-total-h .cell-val { color: #1b5e20; font-weight: 700; }

/* Zero value muting */
.cell-zero { color: #d0d0d0 !important; }

/* ── Footer totals row ───────────────────────────────────────── */
.ts-grid tfoot tr.totals-row td {
  font-weight: 700;
  font-size: 12px;
  padding: 5px 6px;
  text-align: center;
  color: #263238;
}
.ts-grid tfoot td.col-total-sum { color: #1b5e20; font-size: 13px; }
.ts-grid tfoot td.col-ot-sum    { color: #e65100; }
.ts-grid tfoot td.col-bank-sum  { color: #f57f17; }

/* ── Accordion wrapper ───────────────────────────────────────── */
.ts-accordion {
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.ts-acc-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  background: #f0f4f8;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #37474f;
  text-align: left;
}
.ts-acc-toggle:hover { background: #e4eaf0; }
.ts-acc-chevron { font-size: 10px; transition: transform .15s; }
.ts-acc-chevron.acc-open { transform: rotate(180deg); }
.ts-acc-body { overflow: hidden; }

/* ── Accrual panel ───────────────────────────────────────────── */
.ts-accrual-panel {
  padding: 14px 18px;
}
.accrual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.accrual-card {
  border-radius: 4px;
  padding: 10px 14px;
  border-left: 4px solid #ccc;
  background: #fafafa;
}
.accrual-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.accrual-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 1px 0;
}
.accrual-row.accrual-total {
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
  margin-top: 4px;
  padding-top: 4px;
  padding-bottom: 4px;
  margin-bottom: 4px;
  font-weight: 700;
  font-size: 13px;
}
.accrual-row.accrual-proj {
  color: #888;
  font-style: italic;
}
.accrual-val { font-variant-numeric: tabular-nums; }

/* ── Comments panel ──────────────────────────────────────────── */
.ts-comments-panel {
  padding: 14px 18px;
}

/* ── Column visibility panel ─────────────────────────────────── */
.col-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 280px;
  background: #fff;
  border-left: 1px solid #ccc;
  box-shadow: -4px 0 16px rgba(0,0,0,.1);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.col-panel.hidden { display: none; }
.col-panel-inner  { padding: 20px; flex: 1; overflow-y: auto; }
.col-panel-inner h3 { font-size: 14px; margin-bottom: 4px; }
.col-panel-inner .hint { font-size: 11px; color: #888; margin-bottom: 12px; }
.col-panel-footer {
  padding: 14px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
}

/* ── Category column header chip ────────────────────────────── */
th.col-category {
  position: relative;
  white-space: normal;
  min-width: 60px;
}
th.col-category .cat-label {
  display: block;
  font-size: 13px;
  color: #000;
  text-align: center;
  white-space: normal;
}

/* ── Auto-save status indicator ─────────────────────────────── */
.autosave-status {
  display: inline-block;
  width: 80px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: center;
  box-sizing: border-box;
}
.autosave-pending { background: #fff3e0; color: #e65100; }
.autosave-saving  { background: #e3f2fd; color: #0277bd; }
.autosave-saved   { background: #e8f5e9; color: #2e7d32; }
.autosave-error   { background: #ffebee; color: #c62828; }

/* ── Unsaved indicator ───────────────────────────────────────── */
.ts-grid tr.row-dirty td:first-child::before {
  content: '●';
  position: absolute;
  left: 2px;
  font-size: 8px;
  color: #0078d4;
}

/* ── Disabled submit button ──────────────────────────────────── */
#btn-submit:disabled {
  background: #d0d0d0 !important;
  color: #888 !important;
  border-color: #bbb !important;
  opacity: 1;
  pointer-events: auto;
  cursor: not-allowed;
}

/* ── Approval status on review modal ────────────────────────── */
.review-summary { background: #f5f5f5; border-radius: 4px; padding: 14px; margin-bottom: 16px; }
.review-summary dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 10px; }
.review-summary dt { font-weight: 600; font-size: 12px; color: #666; }
.review-summary dd { font-size: 13px; }
.review-actions textarea { width: 100%; margin-bottom: 12px; }
.review-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Dark Theme overrides ────────────────────────────────────── */
[data-theme="dark"] .col-panel { background: var(--color-bg); border-left-color: var(--color-border); color: var(--color-text); }
[data-theme="dark"] .col-panel-inner .hint { color: var(--color-text-mute); }
[data-theme="dark"] .col-panel-footer { border-top-color: var(--color-border); }
[data-theme="dark"] .ts-toolbar { border-bottom-color: var(--color-border); }
[data-theme="dark"] .sel-month,
[data-theme="dark"] .sel-year  { background: #2b2f45; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .btn-nav   { background: #353a54; border-color: var(--color-border); color: var(--color-text-mute); }
[data-theme="dark"] .btn-nav:hover { background: #404666; border-color: var(--color-primary); color: var(--color-text); }
[data-theme="dark"] .btn-today { background: #353a54; border-color: var(--color-border); color: var(--color-text); }
[data-theme="dark"] .undo-redo-group { border-left-color: var(--color-border); }

[data-theme="dark"] .ts-grid-wrap { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .ts-scroll-outer { background: var(--color-surface) !important; }

/* Frozen columns (Date/Day) — override the !important light-grey rule */
[data-theme="dark"] .col-frozen { background: #404666 !important; color: var(--color-text) !important; }

/* Header row text color (Date/Day/Time cols) */
[data-theme="dark"] .ts-header-cols th,
[data-theme="dark"] .ts-header-groups th { color: var(--color-text) !important; }

/* Only override header cells that DON'T have an inline background (i.e. not colored category headers) */
[data-theme="dark"] .ts-grid thead th:not([style*="background"]) { background: #404666; color: var(--color-text); border-color: var(--color-border); }
/* Colored headers (category/holiday/leave): force black text. !important beats JS inline color. No opacity — keeps header fully opaque over scrolling rows. */
[data-theme="dark"] .ts-grid thead th[style*="background"]       { color: #000 !important; border-color: var(--color-border); }

[data-theme="dark"] .ts-grid tfoot td  { background: #404666 !important; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .ts-grid tfoot tr.totals-row td { color: var(--color-text) !important; }
[data-theme="dark"] .ts-grid tfoot td.col-total-sum { color: #7dd89a !important; }
[data-theme="dark"] .ts-grid tfoot td.col-ot-sum    { color: #ffaa66 !important; }
[data-theme="dark"] .ts-grid tfoot td.col-bank-sum  { color: #ffd060 !important; }
[data-theme="dark"] .ts-grid td,
[data-theme="dark"] .ts-grid th        { border-color: var(--color-border); }
[data-theme="dark"] .ts-grid tbody tr td { background: #19212e; color: #fff; }
[data-theme="dark"] .ts-grid tbody tr.is-weekend td { background: #2b2f45 !important; }
[data-theme="dark"] .ts-grid tbody tr.is-holiday td { background: #0d2d42 !important; }
[data-theme="dark"] .ts-grid tbody tr.is-today td   { background: #0d2d42 !important; }
[data-theme="dark"] .ts-grid tbody tr.is-today .col-date { background-color: #3a3600 !important; color: #ffd740 !important; }
/* Force all data cell text and inputs to white, overriding light-mode colours */
[data-theme="dark"] .ts-grid tbody td .cell-val,
[data-theme="dark"] .ts-grid tbody td input        { color: #fff !important; }
[data-theme="dark"] .ts-grid input[type=number]     { background: transparent; color: #fff; border-color: transparent; }
[data-theme="dark"] .ts-grid input[type=number]:focus { border-color: var(--color-primary); background: #2b2f45; }
[data-theme="dark"] .ts-grid input[type=time]        { color-scheme: dark; }
[data-theme="dark"] .ts-grid input[type=time]:focus  { border-color: var(--color-primary); background: #2b2f45; color: #fff; }
[data-theme="dark"] .ts-grid input:focus             { background: #2b2f45; }
[data-theme="dark"] .ts-grid input[type=text]       { background: #2b2f45; color: #fff; border-color: var(--color-border); }

[data-theme="dark"] .ts-match-cell.ts-match-good { background: #253828 !important; color: #90d89a !important; }
[data-theme="dark"] .ts-match-cell.ts-match-bad  { background: #4a2828 !important; color: #f5aaaa !important; }
[data-theme="dark"] .hours-mismatch              { background: #4a2828 !important; color: #f5aaaa !important; }
[data-theme="dark"] .ts-grid tbody td.cell-clocked.row-hours-mismatch,
[data-theme="dark"] .ts-grid tbody td.cell-total-h.row-hours-mismatch { background: #4a2828 !important; }
[data-theme="dark"] .ts-grid tbody td.cell-clocked.row-hours-mismatch .cell-val,
[data-theme="dark"] .ts-grid tbody td.cell-total-h.row-hours-mismatch .cell-val { color: #f5aaaa !important; }

[data-theme="dark"] .ts-grid td.col-day,
[data-theme="dark"] .ts-grid th.col-day { border-right-color: #606880 !important; }
[data-theme="dark"] .btn-copy-day  { background: rgba(100,160,255,.15); color: #6ab0ff; }
[data-theme="dark"] .btn-copy-day:hover  { background: rgba(100,160,255,.3); }
[data-theme="dark"] .btn-clear-day { background: rgba(255,120,120,.12); color: #ff8080; }
[data-theme="dark"] .btn-clear-day:hover { background: rgba(255,120,120,.28); }

[data-theme="dark"] .ts-accordion  { border-color: var(--color-border); }
[data-theme="dark"] .ts-acc-toggle { background: #404666; border-color: var(--color-border); color: var(--color-text); }
[data-theme="dark"] .ts-acc-toggle:hover { background: #4a5070; }
[data-theme="dark"] .ts-acc-body   { border-color: var(--color-border); background: var(--color-surface); }

/* Leave balance cards — lighter so text is readable */
[data-theme="dark"] .accrual-card  { background: #404666 !important; border-color: var(--color-border); color: var(--color-text) !important; }
[data-theme="dark"] .accrual-card-title { color: var(--color-text) !important; }
[data-theme="dark"] .accrual-row   { border-bottom-color: var(--color-border); color: var(--color-text); }
[data-theme="dark"] .accrual-row .accrual-label { color: var(--color-text-mute); }
[data-theme="dark"] .accrual-row.accrual-total  { border-top-color: var(--color-border); color: var(--color-text); }

[data-theme="dark"] .review-summary { background: #2b2f45; }
[data-theme="dark"] .review-summary dt { color: var(--color-text-mute); }

[data-theme="dark"] #btn-submit:disabled { background: #404666 !important; color: #606880 !important; border-color: var(--color-border) !important; }

[data-theme="dark"] .autosave-saved   { background: #253828; color: #90d89a; }
[data-theme="dark"] .autosave-error   { background: #4a2828; color: #f5aaaa; }
[data-theme="dark"] .autosave-pending { background: #3d3520; color: #f5d080; }

/* ── Mobile: day cards ───────────────────────────────────────── */
#ts-day-list { display: none; }

.ts-day-card {
  display: flex;
  align-items: center;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
  overflow: hidden;
  touch-action: manipulation;
  transition: border-color .15s;
}
.ts-day-card[onclick], .ts-day-card.clickable { cursor: pointer; }
.ts-day-card:active { background: var(--color-bg, #f3f2f1); }
.ts-day-card.ts-day-today { border-color: var(--color-primary, #0078d4); }
.ts-day-card.ts-day-weekend { opacity: .6; }
.ts-day-stripe { width: 4px; align-self: stretch; flex-shrink: 0; }
.ts-day-main { flex: 1; padding: 10px 12px; min-width: 0; }
.ts-day-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 2px;
  gap: 4px;
}
.ts-day-label { font-size: 13px; font-weight: 600; }
.ts-day-in-out {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-mute, #605e5c);
  white-space: nowrap;
  text-align: center;
}
.ts-day-in-out-empty { pointer-events: none; }
.ts-day-total { font-size: 13px; font-weight: 700; color: var(--color-primary, #0078d4); white-space: nowrap; text-align: right; }
.ts-day-total-empty { pointer-events: none; }
.ts-day-holiday-info { font-size: 11px; color: #e65100; margin-top: 2px; }
.ts-day-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.ts-day-pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; }
.ts-day-pill-more { background: var(--color-border) !important; color: var(--color-text-muted, #888) !important; letter-spacing: 2px; }
.ts-day-chevron { color: var(--color-text-mute, #605e5c); flex-shrink: 0; margin: 0 10px; }

.ts-mobile-summary {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
}
.ts-msummary-total {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary, #0078d4);
}
.ts-msummary-expected {
  font-size: 13px;
  color: var(--color-text-muted, #888);
}
.ts-msummary-status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.ts-msummary-status.good { background: #dff6dd; color: #107c10; }
.ts-msummary-status.bad  { background: #fde7e9; color: #a4262c; }

/* ── Mobile: bottom sheet ────────────────────────────────────── */
.ts-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 490;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.ts-sheet-backdrop.visible { opacity: 1; pointer-events: auto; }

.ts-bottom-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--color-surface, #fff);
  border-radius: 16px 16px 0 0;
  z-index: 500;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  box-shadow: 0 -4px 24px rgba(0,0,0,.22);
}
.ts-bottom-sheet.open { transform: translateY(0); }

.ts-sheet-handle-bar { display: flex; justify-content: center; padding: 10px 0 2px; }
.ts-sheet-handle { width: 36px; height: 4px; background: var(--color-border, #e0e0e0); border-radius: 2px; }

.ts-sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 16px 12px;
  border-bottom: 1px solid var(--color-border, #e0e0e0);
}
.ts-sheet-date-label { font-size: 16px; font-weight: 700; }
.ts-sheet-close-btn {
  width: 32px; height: 32px; background: none; border: none;
  font-size: 16px; cursor: pointer;
  color: var(--color-text-mute, #605e5c);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; touch-action: manipulation;
}
.ts-sheet-close-btn:hover { background: var(--color-bg, #f3f2f1); }

.ts-sheet-body { padding: 12px 16px 32px; }

.ts-sheet-holiday-notice {
  background: #fff8e1; color: #e65100;
  font-size: 12px; padding: 8px 12px;
  border-radius: 6px; margin-bottom: 12px;
}
.ts-sheet-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-mute, #605e5c);
  margin: 16px 0 4px;
}
.ts-sheet-field-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--color-border, #e0e0e0);
  gap: 10px;
}
.ts-sheet-field-row:last-of-type { border-bottom: none; }
.ts-sheet-label { font-size: 13px; font-weight: 500; flex: 1; }
.ts-sheet-input {
  width: 110px; text-align: right;
  padding: 6px 8px;
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 4px;
  font-size: 14px; font-family: inherit;
  background: var(--color-bg, #f3f2f1);
  color: var(--color-text, #323130);
  flex-shrink: 0; touch-action: manipulation;
}
.ts-sheet-input:focus { outline: none; border-color: var(--color-primary, #0078d4); }
.ts-sheet-num { width: 90px; }
.ts-sheet-readonly-val { font-size: 14px; font-weight: 600; color: var(--color-text-mute, #605e5c); }
.ts-banked-wrap { display: flex; align-items: center; gap: 6px; }
.ts-banked-sign-btn {
  padding: 6px 10px;
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 4px;
  background: var(--color-bg, #f3f2f1);
  color: var(--color-text, #323130);
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  flex-shrink: 0;
  line-height: 1;
}
[data-theme="dark"] .ts-banked-sign-btn { background: #252840; color: var(--color-text); border-color: var(--color-border); }

.ts-sheet-total-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0 10px;
  border-top: 2px solid var(--color-border, #e0e0e0);
  margin-top: 10px; font-size: 14px;
}
.ts-sheet-total-bar strong { font-size: 20px; color: var(--color-primary, #0078d4); }
.ts-sheet-save-btn { width: 100%; padding: 12px; font-size: 15px; justify-content: center; touch-action: manipulation; margin-top: 4px; }

/* ── Dark theme: mobile additions ────────────────────────────── */
[data-theme="dark"] .ts-day-card              { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .ts-day-card:active       { background: var(--color-bg); }
[data-theme="dark"] .ts-mobile-summary        { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .ts-msummary-status.good  { background: #253828; color: #90d89a; }
[data-theme="dark"] .ts-msummary-status.bad   { background: #4a2828; color: #f5aaaa; }
[data-theme="dark"] .ts-bottom-sheet          { background: var(--color-surface); }
[data-theme="dark"] .ts-sheet-holiday-notice  { background: #4a3a00; color: #f9c25a; }
[data-theme="dark"] .ts-sheet-input           { background: #252840; color: var(--color-text); border-color: var(--color-border); }

/* ── Mobile timesheet ────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Switch grid → card list */
  .ts-scroll-outer { display: none; }
  #ts-day-list { display: flex; flex-direction: column; gap: 6px; }
  .ts-mobile-summary { display: flex; margin-bottom: 0; }

  /* Sticky header: toolbar + banners + summary bar */
  #ts-mobile-header {
    position: sticky;
    top: var(--header-h);
    z-index: 100;
    background: var(--color-bg, #f3f2f1);
    padding-bottom: 8px;
  }

  /* Hide desktop columns button */
  #btn-manage-cols { display: none; }

  /* Show topbar categories button */
  .mobile-ts-cats-btn { display: flex; }

  /* Mobile categories panel: full-width drawer */
  .col-panel { width: 100%; border-left: none; border-top: 1px solid #ccc; }

  /* Bigger accordion tap targets */
  .ts-acc-toggle { padding: 12px 16px; font-size: 14px; }

  /* Balance cards go single column */
  .accrual-grid { grid-template-columns: 1fr; }

  /* Clear every scroll container between #ts-mobile-header and the viewport so
     position:sticky fires against the real page scroll (html root), not a
     non-scrolling intermediate container.
     - body gets overflow-y:auto from main.css mobile reset; with height:auto it
       never actually scrolls, trapping sticky permanently.
     - app-main gets overflow-y:auto on desktop; the single-axis override in
       main.css mobile is a no-op (CSS forces both axes to auto when one is visible
       and the other is not). */
  body.page-timesheet { overflow: visible; }
  .page-timesheet .app-main { overflow: visible; padding-top: var(--header-h); }
  .timesheet-page { overflow: visible; height: auto; }

  /* Wrapper must not clip the day list */
  .ts-wrapper { overflow: visible; flex: none; }

  /* Toolbar: nav row full-width, then status (30%) + actions (70%) on same row */
  .ts-toolbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .ts-toolbar-left   { order: 1; flex: 0 0 100%; min-width: 0; justify-content: center; }
  .ts-toolbar-center { order: 2; flex: 0 0 30%; display: flex; align-items: center; justify-content: center; padding: 0; min-width: 0; }
  .ts-toolbar-right  { order: 2; flex: 1 0 0; flex-wrap: wrap; gap: 6px; }
  .ts-toolbar-right .btn { flex: 1; justify-content: center; }
  .autosave-status { display: none; }

  /* Month/year selects slightly smaller */
  .sel-month, .sel-year { font-size: 13px; }
}

/* ── Very narrow phones (Galaxy S-series, 360px) ─────────────── */
@media (max-width: 380px) {
  .ts-toolbar { padding: 8px 6px; }
  .ts-toolbar-left { gap: 4px; }
  .btn-today { padding: 4px 6px; }
  .sel-month, .sel-year { padding: 5px 3px; }
  .undo-redo-group { margin-left: 2px; padding-left: 6px; }
}

/* ── Due Date Banner ─────────────────────────────────────────────────────── */
#ts-due-banner { margin-bottom: 10px; }

.ts-due-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}
.due-banner-icon { font-size: 16px; flex-shrink: 0; }
.due-banner-text { line-height: 1.4; }

/* Info: neutral blue */
.due-banner-info {
  background: #e8f4fd;
  border-color: #b3d9f5;
  color: #1a5276;
}
/* Soon: amber */
.due-banner-soon {
  background: #fef9e7;
  border-color: #f9e08a;
  color: #7d6008;
}
/* Urgent: red */
.due-banner-urgent {
  background: #fdedec;
  border-color: #f5b7b1;
  color: #922b21;
}

/* Dark mode */
[data-theme="dark"] .due-banner-info   { background: #0d2d42; border-color: #1a5276; color: #aed6f1; }
[data-theme="dark"] .due-banner-soon   { background: #3d3000; border-color: #7d6008; color: #f9e08a; }
[data-theme="dark"] .due-banner-urgent { background: #3d0a0a; border-color: #922b21; color: #f1948a; }

/* ── Due Date Grid Marker Row ────────────────────────────────────────────── */
.ts-due-marker-row {
  pointer-events: none;
}
.ts-grid tbody tr.ts-due-marker-row td.ts-due-marker-cell {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #154360 !important;
  background: linear-gradient(90deg, #aed6f1 0%, #d6eaf8 40%, #d6eaf8 100%) !important;
  border-top: 2px solid #2e86c1 !important;
  border-bottom: 2px solid #2e86c1 !important;
  box-shadow: inset 4px 0 0 #2e86c1;
}
.ts-due-marker-flag {
  color: #1a6fa8;
  margin-right: 5px;
}

[data-theme="dark"] .ts-grid tbody tr.ts-due-marker-row td.ts-due-marker-cell {
  background: linear-gradient(90deg, #1a4a6e 0%, #0d2d42 40%, #0d2d42 100%) !important;
  color: #aed6f1 !important;
  border-top-color: #2e86c1 !important;
  border-bottom-color: #2e86c1 !important;
  box-shadow: inset 4px 0 0 #2e86c1;
}
[data-theme="dark"] .ts-due-marker-flag { color: #5dade2; }

/* ── Due date marker — mobile card pill ─────────────────────────────────── */
.ts-due-marker-pill {
  font-size: 11px;
  font-weight: 600;
  color: #154360;
  background: linear-gradient(90deg, #aed6f1, #d6eaf8);
  border-left: 3px solid #2e86c1;
  border-radius: 0 6px 6px 0;
  padding: 5px 10px;
  margin: -2px 0 4px 0;
}
[data-theme="dark"] .ts-due-marker-pill {
  background: linear-gradient(90deg, #1a4a6e, #0d2d42);
  border-left-color: #2e86c1;
  color: #aed6f1;
}

/* Admin due dates table — past rows dimmed */
.dd-row-past td { opacity: 0.45; }

/* ── Pay period separator — shared label styles ─────────────────────────── */
.ts-period-sep-prev,
.ts-period-sep-curr  { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.ts-period-sep-prev  { color: var(--color-text-mute, #605e5c); }
.ts-period-sep-curr  { color: var(--color-primary, #0078d4); }
.ts-period-sep-arrow { font-size: 11px; color: var(--color-text-mute, #605e5c); margin: 0 8px; }

/* Grid view separator row */
.ts-period-sep-row { pointer-events: none; }
.ts-period-sep-cell {
  padding: 5px 14px !important;
  background: var(--color-bg, #f3f2f1) !important;
  border-top: 2px dashed var(--color-border, #e0e0e0) !important;
  border-bottom: 2px dashed var(--color-border, #e0e0e0) !important;
  text-align: center;
}
[data-theme="dark"] .ts-period-sep-cell {
  background: var(--color-bg) !important;
  border-top-color: var(--color-border) !important;
  border-bottom-color: var(--color-border) !important;
}

/* Desktop card view separator */
.ts-cv-period-sep {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 6px 12px;
  margin: 2px 0;
  border-top: 2px dashed var(--color-border, #e0e0e0);
  border-bottom: 2px dashed var(--color-border, #e0e0e0);
  background: var(--color-bg, #f3f2f1);
}
[data-theme="dark"] .ts-cv-period-sep {
  background: var(--color-bg);
  border-top-color: var(--color-border);
  border-bottom-color: var(--color-border);
}

/* Mobile card list separator */
.ts-day-period-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 5px 12px;
  margin: 2px 0;
  border-top: 2px dashed var(--color-border, #e0e0e0);
  border-bottom: 2px dashed var(--color-border, #e0e0e0);
  background: var(--color-bg, #f3f2f1);
}
[data-theme="dark"] .ts-day-period-sep {
  background: var(--color-bg);
  border-top-color: var(--color-border);
  border-bottom-color: var(--color-border);
}

/* ══════════════════════════════════════════════════════════════
   PERCENTAGE-BASED TIMESHEET: hidden columns
══════════════════════════════════════════════════════════════ */
.ts-pct-mode th.col-banked,
.ts-pct-mode td.cell-banked,
.ts-pct-mode td.col-bank-sum,
.ts-pct-mode .pct-blank-banked,
.ts-pct-mode th.col-away,
.ts-pct-mode td.cell-away,
.ts-pct-mode td.col-away-sum { display: none; }

/* ══════════════════════════════════════════════════════════════
   PERCENTAGE-BASED TIMESHEET ROW
══════════════════════════════════════════════════════════════ */
.ts-pct-row td {
  background: linear-gradient(180deg, #f0f7ff 0%, #e8f3fe 100%);
  border-top: none !important;
  border-bottom: 18px solid #fff !important;
  box-shadow: inset 0 2px 0 #0078d4;
  padding: 8px 4px;
  vertical-align: middle;
}

/* cols 1-2: "Monthly Work Hrs" label
   padding:0 so no in-flow content → table layout ignores this cell's text width,
   keeping col-date and col-day at their natural min-widths (38px + 32px). */
.pct-total-cell {
  position: sticky;
  left: 0;
  z-index: 6;
  padding: 0 !important;
}
/* Label is absolutely positioned so it doesn't participate in table column sizing */
.pct-total-cell .pct-total-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: normal;
  text-align: center;
  padding: 0 3px;
  overflow: hidden;
}
/* col 3: hours input */
.pct-hours-cell {
  padding: 4px 6px !important;
  text-align: center;
}
/* Clocked Hrs col: category percentages label */
.pct-cat-label-cell {
  padding: 5px 8px !important;
  white-space: nowrap;
  vertical-align: middle;
  border-right: 2px solid #b0bec5 !important;
  overflow: hidden;
}
.pct-cat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #0078d4;
  white-space: nowrap;
}
[data-theme="dark"] .pct-cat-label { color: #60b4f8; }
.pct-total-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.pct-total-label {
  font-size: 11px;
  font-weight: 700;
  color: #0052a3;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.pct-hours-input {
  width: 70px;
  padding: 3px 5px;
  border: 1px solid #90caf9;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #0d47a1;
  background: #fff;
  text-align: right;
  flex-shrink: 0;
}
.pct-hours-input:focus {
  outline: none;
  border-color: #0078d4;
  box-shadow: 0 0 0 2px rgba(0,120,212,.2);
}
.pct-hours-display {
  font-size: 14px;
  font-weight: 700;
  color: #0d47a1;
}

/* Per-category % input cells */
.pct-cat-cell {
  position: relative;
  min-width: 58px;
  text-align: center;
  padding: 4px 2px !important;
  overflow: hidden;
}
.pct-cat-input {
  width: 42px;
  padding: 3px 4px;
  border: 1px solid #90caf9;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  background: #fff;
  color: #0d47a1;
}
.pct-cat-input:focus {
  outline: none;
  border-color: #0078d4;
  box-shadow: 0 0 0 2px rgba(0,120,212,.2);
}
.pct-sym {
  font-size: 10px;
  color: #546e7a;
  margin-left: 1px;
}
.pct-readonly {
  font-size: 12px;
  font-weight: 600;
  color: #0d47a1;
}

/* Leave hour cells in pct row */
.pct-leave-cell {
  min-width: 60px;
  text-align: center;
  padding: 4px 2px !important;
}
.pct-leave-input {
  width: 50px;
  padding: 3px 4px;
  border: 1px solid #ffcc80;
  border-radius: 4px;
  font-size: 12px;
  text-align: right;
  background: #fff8f0;
  color: #bf360c;
}
.pct-leave-input:focus {
  outline: none;
  border-color: #fb8c00;
  box-shadow: 0 0 0 2px rgba(251,140,0,.18);
}

/* Total display in pct row */
.pct-total-display {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #1b5e20;
  min-width: 60px;
}

/* Blank filler cells */
.pct-blank {
  background: linear-gradient(180deg, #f0f7ff 0%, #e8f3fe 100%);
}

/* Dark mode */
[data-theme="dark"] .ts-pct-row td {
  background: linear-gradient(180deg, #0d2137 0%, #0a1c30 100%);
  border-bottom-color: #2b2f45 !important;
  box-shadow: inset 0 2px 0 #1e88e5;
}
[data-theme="dark"] .pct-total-label { color: #64b5f6; }
[data-theme="dark"] .pct-hours-input  { background: #0d2137; border-color: #1e5c8a; color: #90caf9; }
[data-theme="dark"] .pct-hours-display{ color: #90caf9; }
[data-theme="dark"] .pct-cat-input    { background: #0d2137; border-color: #1e5c8a; color: #90caf9; }
[data-theme="dark"] .pct-sym          { color: #78909c; }
[data-theme="dark"] .pct-leave-input  { background: #1a0f05; border-color: #6d3600; color: #ffcc80; }
[data-theme="dark"] .pct-total-display{ color: #66bb6a; }
[data-theme="dark"] .pct-blank        { background: linear-gradient(180deg, #0d2137 0%, #0a1c30 100%); }
[data-theme="dark"] .pct-readonly     { color: #90caf9; }

/* ── Mobile pct config panel ─────────────────────────────────── */
.ts-pct-mobile-card { cursor: default; align-items: stretch; }
.ts-pct-mob-panel { flex: 1; padding: 10px 14px; min-width: 0; }
.ts-pct-mob-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #7b5ea7;
  margin-bottom: 6px;
}
.ts-pct-mob-section-cats { margin-top: 10px; }
.ts-pct-mob-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.ts-pct-mob-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text, #333);
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.ts-pct-mob-input { width: 80px !important; text-align: right; }
.ts-pct-mob-pct-wrap { display: flex; align-items: center; gap: 3px; }
.ts-pct-mob-val { font-size: 14px; font-weight: 600; color: #7b5ea7; }
[data-theme="dark"] .ts-pct-mob-section { color: #b39ddb; }
[data-theme="dark"] .ts-pct-mob-val     { color: #b39ddb; }

/* ══════════════════════════════════════════════════════════════
   VIEW TOGGLE BUTTON & WEEKEND CHECKBOX (toolbar)
══════════════════════════════════════════════════════════════ */
#btn-view-toggle {
  width: 30px;
  height: 30px;
}
#btn-view-toggle.card-active {
  background: var(--color-primary, #0078d4);
  border-color: var(--color-primary, #0078d4);
  color: #fff;
}
#btn-view-toggle.card-active:hover {
  background: #005fa3;
  border-color: #005fa3;
}
.ts-cv-weekend-lbl {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-mute, #605e5c);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  padding: 0 6px;
  border-right: 1px solid var(--color-border, #e0e0e0);
  margin-right: 2px;
}
.ts-cv-weekend-lbl input { cursor: pointer; }

/* ══════════════════════════════════════════════════════════════
   DESKTOP CARD VIEW — week-based layout
══════════════════════════════════════════════════════════════ */
#ts-card-view {
  flex: 1;
  overflow-y: auto;
  padding: 2px 0 12px;
}

/* Column headers (Mon, Tue, …) */
.ts-cv-header-row {
  display: grid;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0 2px;
}
.ts-cv-header-row.cols-7 { grid-template-columns: repeat(7, 1fr); }
.ts-cv-header-row.cols-5 { grid-template-columns: repeat(5, 1fr); }
.ts-cv-day-hdr {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-mute, #605e5c);
  padding: 4px 0;
}

/* Week rows */
.ts-cv-week-row {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
  padding: 0 2px;
}
.ts-cv-week-row.cols-7 { grid-template-columns: repeat(7, 1fr); }
.ts-cv-week-row.cols-5 { grid-template-columns: repeat(5, 1fr); }

/* Individual day card */
.ts-cv-day {
  display: flex;
  flex-direction: column;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
  overflow: hidden;
  min-height: 70px;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.ts-cv-day.clickable {
  cursor: pointer;
}
.ts-cv-day.clickable:hover {
  border-color: var(--color-primary, #0078d4);
  box-shadow: 0 2px 8px rgba(0,120,212,.12);
}
.ts-cv-day.ts-cv-day-empty {
  background: var(--color-bg, #f3f2f1);
  border-color: transparent;
  cursor: default;
  min-height: 70px;
}
.ts-cv-day.ts-cv-day-today {
  border-color: var(--color-primary, #0078d4);
}
.ts-cv-day.ts-cv-day-weekend { opacity: .65; }
.ts-cv-day.ts-cv-day-mismatch { background: #fce4ec !important; }
[data-theme="dark"] .ts-cv-day.ts-cv-day-mismatch { background: #4a2828 !important; }
.ts-day-card.ts-day-mismatch { background: #fce4ec !important; }
[data-theme="dark"] .ts-day-card.ts-day-mismatch { background: #4a2828 !important; }

/* Left color stripe */
.ts-cv-stripe {
  width: 4px;
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 8px 0 0 8px;
}

/* Card body */
.ts-cv-body {
  flex: 1;
  padding: 8px 8px 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

/* Date number + total hours row */
.ts-cv-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
}
.ts-cv-date {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text, #323130);
  display: flex;
  align-items: center;
  gap: 4px;
}
.ts-cv-today-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-primary, #0078d4);
  flex-shrink: 0;
}
.ts-cv-in-out {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-mute, #605e5c);
  white-space: nowrap;
  text-align: center;
}
.ts-cv-in-out-empty { pointer-events: none; }
.ts-cv-total {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary, #0078d4);
  white-space: nowrap;
  text-align: right;
}
.ts-cv-total-empty { pointer-events: none; }

/* Holiday badge */
.ts-cv-holiday-badge {
  font-size: 10px;
  color: #e65100;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .ts-cv-holiday-badge { color: #f9c25a; }

/* Category/leave pills */
.ts-cv-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}
.ts-cv-pill {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-cv-pill-more {
  background: var(--color-border) !important;
  color: var(--color-text-mute, #888) !important;
  letter-spacing: 1px;
}

/* Copy / Clear action buttons (absolutely positioned, shown on card hover) */
.ts-cv-actions {
  position: absolute;
  bottom: 4px;
  right: 5px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .15s;
}
.ts-cv-day.clickable:hover .ts-cv-actions { opacity: 1; }
.ts-cv-copy-btn,
.ts-cv-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 1px solid var(--color-border, #e0e0e0);
  background: var(--color-surface, #fff);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  padding: 0;
  color: var(--color-text-mute, #605e5c);
}
.ts-cv-copy-btn:hover {
  background: #e3f0fd;
  border-color: #0078d4;
  color: #0078d4;
}
.ts-cv-clear-btn:hover {
  background: #fce4ec;
  border-color: #c62828;
  color: #c62828;
}

/* Due date marker between week rows */
.ts-cv-due-marker {
  font-size: 11px;
  font-weight: 600;
  color: #154360;
  background: linear-gradient(90deg, #aed6f1, #d6eaf8);
  border-left: 3px solid #2e86c1;
  border-radius: 0 6px 6px 0;
  padding: 4px 10px;
  margin: -2px 2px 6px;
}
[data-theme="dark"] .ts-cv-due-marker {
  background: linear-gradient(90deg, #1a4a6e, #0d2d42);
  border-left-color: #2e86c1;
  color: #aed6f1;
}

/* Summary strip above card view (mirrors mobile summary) */
#ts-cv-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
  margin-bottom: 10px;
}
.ts-cv-summary-total {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary, #0078d4);
}
.ts-cv-summary-status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.ts-cv-summary-status.good { background: #dff6dd; color: #107c10; }
.ts-cv-summary-status.bad  { background: #fde7e9; color: #a4262c; }
#ts-cv-summary-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 8px;
  margin-top: 10px;
}
[data-theme="dark"] #ts-cv-summary { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] #ts-cv-summary-bottom { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .ts-cv-summary-status.good { background: #253828; color: #90d89a; }
[data-theme="dark"] .ts-cv-summary-status.bad  { background: #4a2828; color: #f5aaaa; }

/* ══════════════════════════════════════════════════════════════
   DESKTOP CARD EDIT MODAL
══════════════════════════════════════════════════════════════ */
.ts-card-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 490;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.ts-card-modal-backdrop.visible { opacity: 1; pointer-events: auto; }

.ts-card-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -52%);
  background: var(--color-surface, #fff);
  border-radius: 12px;
  z-index: 500;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.28);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.ts-card-modal.open {
  opacity: 1; pointer-events: auto;
  transform: translate(-50%, -50%);
}

.ts-card-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--color-border, #e0e0e0);
  position: sticky; top: 0;
  background: var(--color-surface, #fff);
  z-index: 1;
  border-radius: 12px 12px 0 0;
}
.ts-card-modal-title { font-size: 16px; font-weight: 700; }
.ts-card-modal-actions { display: flex; gap: 6px; align-items: center; }
.ts-card-modal-copy-btn,
.ts-card-modal-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--color-border, #e0e0e0);
  background: var(--color-bg, #f3f2f1);
  cursor: pointer;
  color: var(--color-text-mute, #605e5c);
  transition: background .12s, border-color .12s;
  padding: 0;
}
.ts-card-modal-copy-btn:hover { background: #e3f0fd; border-color: #0078d4; color: #0078d4; }
.ts-card-modal-clear-btn:hover { background: #fce4ec; border-color: #c62828; color: #c62828; }
.ts-card-modal-close {
  width: 30px; height: 30px; background: none; border: none;
  font-size: 16px; cursor: pointer;
  color: var(--color-text-mute, #605e5c);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.ts-card-modal-close:hover { background: var(--color-bg, #f3f2f1); }

.ts-card-modal-body { padding: 12px 20px 20px; }
.ts-card-modal-holiday {
  background: #fff8e1; color: #e65100;
  font-size: 12px; padding: 8px 12px;
  border-radius: 6px; margin-bottom: 12px;
}
.ts-card-modal-save {
  width: 100%; padding: 10px; font-size: 14px;
  justify-content: center; margin-top: 8px;
}

/* Dark mode */
[data-theme="dark"] .ts-card-modal { background: var(--color-surface); }
[data-theme="dark"] .ts-card-modal-header { background: var(--color-surface); border-bottom-color: var(--color-border); }
[data-theme="dark"] .ts-card-modal-holiday { background: #4a3a00; color: #f9c25a; }
[data-theme="dark"] .ts-card-modal-copy-btn,
[data-theme="dark"] .ts-card-modal-clear-btn { background: #1e2330; border-color: var(--color-border); }
[data-theme="dark"] .ts-card-modal .ts-sheet-input { background: #252840; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .ts-card-modal .ts-sheet-input:focus { border-color: var(--color-primary); }

/* ── Responsive: hide card view on mobile (mobile gets its own day-list) ── */
@media (max-width: 768px) {
  #ts-card-view { display: none !important; }
  #ts-cv-summary { display: none !important; }
  #btn-view-toggle { display: none !important; }
  .ts-cv-weekend-lbl { display: none !important; }
}
