/* OPT-430: Staff / Timesheets page. Uses the app's design tokens
   (--surface/--border/--accent/…) from style.css. The page root claims the
   viewport height and scrolls internally, like the other pages. */

.ts-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 24px;
  gap: 16px;
}

/* ── login gate ─────────────────────────────────────────────────────────── */
.ts-login {
  max-width: 380px;
  margin: 48px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 12px);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ts-login h2 { margin: 0; font-family: var(--serif); font-weight: 500; }
.ts-login-hint { margin: 0; font-size: 13px; color: var(--muted); }
.ts-login-field { display: flex; flex-direction: column; gap: 4px; }
.ts-login-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ts-login-field input { padding: 8px 10px; border: 1px solid var(--border-2); border-radius: var(--r-sm, 6px); background: var(--surface); color: var(--ink); }
.ts-error { color: var(--danger); font-size: 12px; margin: 0; }

/* ── header ─────────────────────────────────────────────────────────────── */
.ts-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ts-header-left { display: flex; flex-direction: column; gap: 8px; }
.ts-week-nav { display: flex; align-items: center; gap: 10px; }
.ts-week-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.ts-header-right { display: flex; align-items: center; gap: 10px; }
.ts-whoami { font-size: 12.5px; color: var(--muted); }

/* ── week grid ──────────────────────────────────────────────────────────── */
.ts-grid-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md, 10px); background: var(--surface); }
table.ts-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ts-grid th, table.ts-grid td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
table.ts-grid thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted);
}
.ts-name-col { min-width: 150px; white-space: nowrap; }
table.ts-grid thead th.ts-name-col { position: sticky; left: 0; z-index: 2; }
.ts-cell { min-width: 92px; }
.ts-staff-name { font-weight: 600; color: var(--ink); }
.ts-you {
  margin-left: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: var(--accent-ink, var(--accent)); background: var(--accent-soft);
  border-radius: 40px; padding: 1px 7px;
}
tr.ts-me { background: var(--accent-soft); }
tr.ts-me .ts-name-col { box-shadow: inset 3px 0 0 var(--accent); }

.ts-chip {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-ink, var(--accent));
  border: 1px solid var(--accent-soft-2, var(--border-2));
  border-radius: var(--r-sm, 6px);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 4px;
}
.ts-chip.leave {
  background: var(--warn-soft, #f4ecd9);
  color: var(--warn, #8a6d1f);
  border-color: var(--warn, #d9c48f);
}
.ts-empty { padding: 24px; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  .ts-page { padding: 14px 12px; }
  .ts-header { flex-direction: column; }
}

/* ── manager editing (OPT-431) ──────────────────────────────────────────── */
.ts-cell.ts-editable { cursor: pointer; }
.ts-cell.ts-editable:hover { background: var(--surface-2); }
.ts-chip.ts-editable { cursor: pointer; }
.ts-chip.ts-editable:hover { filter: brightness(0.96); }
.ts-add-hint { color: var(--faint); font-size: 15px; font-weight: 700; opacity: 0; transition: opacity .1s; }
.ts-cell.ts-editable:hover .ts-add-hint { opacity: 1; }

.ts-editor-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(42, 39, 35, 0.38);
  display: flex; align-items: center; justify-content: center;
}
.ts-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 12px);
  padding: 20px 22px;
  width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 48px -12px rgba(42, 39, 35, 0.4);
}
.ts-editor h3 { margin: 0; font-family: var(--serif); font-weight: 500; }
.ts-editor-field { display: flex; flex-direction: column; gap: 4px; }
.ts-editor-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ts-editor-field input {
  padding: 7px 10px; border: 1px solid var(--border-2); border-radius: var(--r-sm, 6px);
  background: var(--surface); color: var(--ink); font-family: var(--sans);
}
.ts-editor-times { display: flex; gap: 12px; }
.ts-editor-times .ts-editor-field { flex: 1; }
.ts-kind-toggle { display: flex; gap: 6px; }
.ts-kind-toggle button {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border-2); border-radius: 40px;
  background: var(--surface); color: var(--text-secondary); font-size: 13px; font-weight: 600; cursor: pointer;
}
.ts-kind-toggle button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink, var(--accent)); }
.ts-editor-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.ts-editor-actions .danger { margin-left: auto; color: var(--danger); border-color: var(--danger); }

/* ── requests + manager inbox (OPT-432) ─────────────────────────────────── */
.ts-flash {
  background: var(--ok-soft, #e7f2ea); color: var(--ok-strong, #2f6b45);
  border: 1px solid var(--ok, #6fae86); border-radius: var(--r-sm, 6px);
  padding: 8px 12px; font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.ts-flash-x { margin-left: auto; border: none; background: transparent; cursor: pointer; font-size: 16px; color: inherit; line-height: 1; }

.ts-inbox {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg, 12px); padding: 18px 20px;
  width: min(460px, calc(100vw - 32px)); max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 48px -12px rgba(42, 39, 35, 0.4);
}
.ts-inbox-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ts-inbox-head h3 { margin: 0; font-family: var(--serif); font-weight: 500; }
.ts-inbox-list { display: flex; flex-direction: column; gap: 10px; }
.ts-inbox-row {
  display: flex; align-items: flex-start; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm, 6px); padding: 10px 12px;
}
.ts-inbox-info { flex: 1; min-width: 0; }
.ts-inbox-who { font-weight: 700; color: var(--ink); font-size: 13px; }
.ts-inbox-what { font-size: 13px; color: var(--ink-2, var(--ink)); margin-top: 2px; }
.ts-inbox-note { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 3px; }
.ts-inbox-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }

/* ── drag-select leave (OPT-440) ────────────────────────────────────────────── */
.ts-cell.ts-selectable { cursor: pointer; user-select: none; }
.ts-cell.ts-selectable:hover { background: var(--surface-2); }
.ts-cell.ts-selected,
.ts-cell.ts-selected:hover {
  background: var(--warn-soft, #f4ecd9);
  box-shadow: inset 0 0 0 2px var(--warn, #d9c48f);
}
.ts-leave-bar {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: var(--r-md, 10px);
  box-shadow: 0 -4px 14px -6px rgba(42, 39, 35, 0.3);
}
.ts-leave-count { font-size: 13px; font-weight: 600; color: var(--ink); margin-right: auto; }

/* ── holiday allowance (OPT-441) ────────────────────────────────────────────── */
.ts-leave-remaining { font-size: 12.5px; color: var(--muted); margin-right: 8px; }
.ts-leave-remaining.over { color: var(--danger); font-weight: 700; }
.ts-inbox-holiday { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ts-inbox-holiday.over { color: var(--danger); font-weight: 700; }
table.ts-holiday-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ts-holiday-table th {
  text-align: left; padding: 6px 8px; font-size: 11px; font-weight: 600;
  color: var(--muted); border-bottom: 1px solid var(--border-2);
}
table.ts-holiday-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ts-alw-input { width: 64px; padding: 4px 6px; border: 1px solid var(--border-2); border-radius: var(--r-sm, 6px); background: var(--surface); color: var(--ink); }
.ts-holiday-table .ts-neg { color: var(--danger); font-weight: 700; }
