:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8ee;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --primary: #5b5bd6;
  --primary-soft: #eef0ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --neutral: #9ca3af;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --note-body-max: 200px; /* JS overrides to fit 3 cards per viewport */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: auto; height: 36px; border-radius: 6px;
  background: #0b1220; padding: 4px 8px;
  display: block; object-fit: contain;
}
.brand-title { font-weight: 600; font-size: 17px; }
.brand-subtitle { font-size: 12px; color: var(--text-muted); }

/* Right side of the header: signed-in nickname on top, nav below. */
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.current-user { display: flex; align-items: baseline; gap: 6px; font-size: 13px; line-height: 1; }
.current-user-label { color: var(--text-muted); }
.current-user-name { font-weight: 600; color: var(--text); }
.logout-btn {
  margin-left: 6px; padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent;
  font: inherit; font-size: 12px; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
.logout-btn:hover { border-color: var(--danger, #e5484d); color: var(--danger, #e5484d); }

nav { display: flex; gap: 4px; justify-content: flex-end; }
nav button {
  background: transparent; border: none;
  padding: 8px 14px; border-radius: 8px;
  font: inherit; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

main { max-width: 1180px; margin: 28px auto; padding: 0 32px; }
/* The employee detail view is a wide two-column layout (notes + record), so it
   escapes the default reading-width cap and uses (almost) the full viewport. */
main:has(.detail) { max-width: min(1760px, 95vw); }

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
  box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 20px;
}
.filter-bar label { font-size: 13px; color: var(--text-muted); margin-right: 4px; }
.filter-bar input[type=date] {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font: inherit; color: var(--text); background: var(--surface);
}
.preset {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
.preset:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--primary); color: white; border: none;
  padding: 8px 16px; border-radius: 8px; font: inherit; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.btn-primary:hover { filter: brightness(1.05); }
.grow { flex: 1; }

.row-delete {
  background: transparent; color: #991b1b; border: 1px solid #fecaca;
  padding: 4px 10px; border-radius: 6px; font: inherit; font-size: 12px;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.row-delete:hover { background: #fee2e2; border-color: #f87171; }
.row-actions { text-align: right; width: 80px; white-space: nowrap; }
.row-trash, .row-add {
  background: transparent; color: var(--text-muted); border: none;
  padding: 4px 8px; border-radius: 6px; font: inherit; font-size: 16px;
  line-height: 1; cursor: pointer; opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
tbody tr:hover .row-trash, .row-trash:focus,
tbody tr:hover .row-add, .row-add:focus { opacity: 1; }
.row-trash:hover { background: #fee2e2; color: #991b1b; }
.row-add:hover { background: var(--primary-soft); color: var(--primary); }
.sub-actions { margin-top: 10px; text-align: right; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
/* A panel that hosts a date picker must not clip the calendar popup (it opens
   below the filter row, past the panel's bottom edge). Safe because the popup
   is display:none while closed. */
.panel:has(.date-picker) { overflow: visible; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.panel-title { font-weight: 600; }
.panel-meta { font-size: 13px; color: var(--text-muted); display: flex; gap: 0; align-items: baseline; }
.panel-meta > span:first-child { color: var(--text); font-weight: 600; }
.panel-meta-sep { padding: 0 2px; }
/* Round "+" that opens the create-person form (replaces the old header button). */
.add-btn {
  align-self: center; margin-left: 12px;
  width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.add-btn:hover { filter: brightness(1.08); }
.add-btn:active { transform: translateY(1px); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 20px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 14px; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.currency { color: var(--text-muted); font-size: 12px; margin-left: 4px; }

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.pill.planned { background: #e0e7ff; color: #4338ca; }
.pill.paid { background: #d1fae5; color: #065f46; }
.pill.partially_paid { background: #fef3c7; color: #92400e; }
.pill.failed { background: #fee2e2; color: #991b1b; }
.pill.cancelled { background: #f3f4f6; color: #6b7280; }
.pill.refunded { background: #ede9fe; color: #6d28d9; }

.status-select {
  padding: 3px 8px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-size: 11px; font-weight: 600; text-transform: uppercase;
  cursor: pointer; appearance: none; -webkit-appearance: none;
}
.status-select.planned { background: #e0e7ff; color: #4338ca; }
.status-select.paid { background: #d1fae5; color: #065f46; }
.status-select.partially_paid { background: #fef3c7; color: #92400e; }
.status-select.failed { background: #fee2e2; color: #991b1b; }
.status-select.cancelled { background: #f3f4f6; color: #6b7280; }
.status-select.refunded { background: #ede9fe; color: #6d28d9; }
.status-select option { text-transform: none; color: var(--text); background: var(--surface); }

.empty { padding: 60px 20px; text-align: center; color: var(--text-muted); }
.empty-title { font-weight: 600; color: var(--text); margin-bottom: 6px; font-size: 15px; }

.stat-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.sub-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.sub-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.sub-title { font-weight: 600; font-size: 15px; }
.sub-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); }
.sub-amount { font-size: 22px; font-weight: 700; color: var(--text); }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--danger); color: white;
  padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .app-header { padding: 14px 16px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-right { width: 100%; align-items: flex-start; }
  main { padding: 0 16px; }
  .detail-layout { flex-direction: column; }
  .notes-col { max-width: none; width: 100%; }
  .detail-col { flex: 1 1 auto; width: 100%; }
  nav { width: 100%; overflow-x: auto; }
}

/* ---- Login overlay ------------------------------------------------------- */

.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.6);
  z-index: 1000;
}

.login-card {
  background: var(--card, white);
  border-radius: 12px;
  padding: 28px 32px;
  width: min(420px, 92vw);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; gap: 16px;
}

.login-title {
  font-size: 1.2rem; font-weight: 600;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger, #dc2626);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.85rem; color: var(--muted, #64748b); }
.form-hint  { font-size: 0.75rem; color: var(--muted, #94a3b8); }
.form-check { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; }
.form-check input { width: 16px; height: 16px; margin: 0; cursor: pointer; }

/* ---- Per-day hours calendar (person page, below the 3-month window) ---- */
.wtp-tab { display: flex; flex-direction: column; gap: 16px; }

.hours-cal {
  margin-top: 4px;
  padding: 12px;
  border: 1px solid var(--border, #e3e7ef);
  border-radius: 12px;
  background: var(--card, #fff);
}
.hours-cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
}
.hours-cal-title { font-weight: 600; font-size: 15px; min-width: 140px; text-align: center; }

.hours-cal-weekdays,
.hours-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.hours-cal-weekdays { margin-bottom: 4px; }
.hours-cal-weekdays span {
  padding: 2px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #a7adba);
}

.hours-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  /* Colourless by default; days with hours get an inline heat background
     (blue → red) set from JS. A faint border keeps empty cells visible. */
  background: transparent;
  border: 1px solid #eef1f6;
  color: var(--fg, #1f2430);
  font-size: 13px;
}
.hours-cell-day   { font-size: 12px; color: var(--muted, #64748b); }
.hours-cell-hours { font-size: 12px; font-weight: 700; color: #1f2937; }
.hours-cell--muted { opacity: 0.4; border-color: transparent; }
.hours-cell--today { box-shadow: inset 0 0 0 1.5px var(--accent, #2f6df6); }

.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  font-size: 1rem;
}

.btn-secondary {
  background: transparent;
  color: var(--muted, #64748b);
  border: 1px solid var(--border, #e2e8f0);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 8px;
}
.btn-secondary:hover { background: var(--surface-2, #f1f5f9); }

/* ---- Add expense form --------------------------------------------------- */

.add-expense {
  max-width: 640px;
  margin: 24px auto;
  padding: 24px;
  background: var(--card, white);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  display: flex; flex-direction: column; gap: 16px;
}

.add-expense h2 { margin: 0 0 8px; font-size: 1.15rem; font-weight: 600; }

.add-expense input,
.add-expense select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  font-size: 1rem;
  background: white;
}

.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.form-actions {
  display: flex; justify-content: flex-end; margin-top: 8px;
}

.form-flash {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
}

/* ---- Dictionaries ------------------------------------------------------- */

.dictionaries {
  max-width: 720px;
  margin: 24px auto;
  padding: 24px;
  background: var(--card, white);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  display: flex; flex-direction: column; gap: 24px;
}

.dictionaries h2 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.dict-section h3 { margin: 0 0 10px; font-size: 1rem; font-weight: 600; }

.dict-list {
  margin: 0 0 12px; padding: 0;
  border: 1px solid var(--border, #e2e8f0); border-radius: 8px;
  max-height: 260px; overflow: auto;
}
.dict-list-item {
  padding: 8px 12px; border-bottom: 1px solid var(--border, #f1f5f9);
  font-size: 0.95rem;
}
.dict-list-item:last-child { border-bottom: none; }

.dict-add-row { display: flex; gap: 8px; align-items: center; }
.dict-add-row input,
.dict-add-row select {
  padding: 9px 11px; border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px; font-size: 0.95rem; background: white;
}
.dict-add-row input { flex: 1; }

/* ---- Add: expense/subscription segmented toggle ------------------------- */

.segmented { display: flex; gap: 0; margin-bottom: 8px; }
.seg-button {
  flex: 1; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--border, #e2e8f0); background: white;
  font-size: 0.95rem; color: var(--muted, #64748b);
}
.seg-button:first-child { border-radius: 6px 0 0 6px; }
.seg-button:last-child  { border-radius: 0 6px 6px 0; border-left: none; }
.seg-button.active {
  background: var(--primary, #6366f1); color: white;
  border-color: var(--primary, #6366f1);
}

/* ---- Members directory additions ------------------------------------- */
.brand-title {
  font-weight: 600;
  font-size: 16px;
  margin-left: 8px;
}

.uuid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* UUID value + a small copy button, kept on a single line so the long id no
   longer wraps down the panel. The record column is narrow, so the cell hugs
   the right edge (see .detail-row rule) with the button last and always
   visible; the id text truncates before the button ever spills off the card. */
.uuid-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  color: #6b7280;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.copy-btn:hover { color: var(--primary); border-color: var(--primary); }
.copy-btn:active { background: #f3f4f6; }

.detail { max-width: 100%; margin: 24px auto; }
.detail .panel { padding: 22px 26px; }
.detail h2 { margin: 0 0 20px; font-size: 22px; }

/* Two-column detail: HR notes (primary, wide) on the left, the employee
   record (secondary, narrow) on the right. Notes carry Redmine-formatted
   long-form text, so the notes column takes the lion's share of the width. */
.detail-layout { display: flex; gap: 20px; align-items: flex-start; }
.notes-col  { flex: 1 1 auto; min-width: 0; }
.detail-col { flex: 0 0 340px; }

.notes-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.notes-col .panel-title { font-weight: 600; font-size: 16px; }
.icon-btn {
  background: var(--primary-soft); color: var(--primary);
  border: none; border-radius: 8px; width: 34px; height: 34px;
  font-size: 16px; line-height: 1; cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover { background: var(--primary); color: #fff; }

.note-form { margin-bottom: 16px; }
.note-input {
  width: 100%; min-height: 260px; resize: vertical; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font: inherit; font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--surface);
}
.note-input:focus { outline: none; border-color: var(--primary); }
/* Read-only rendered preview shown in place of the textarea when Preview is on.
   Same footprint as the input so toggling doesn't shift the layout. */
.note-preview-body {
  width: 100%; min-height: 260px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; background: var(--surface); overflow-y: auto;
}
.note-page-card .note-preview-body { min-height: 340px; }
.note-hint { margin-top: 6px; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

/* Formatting toolbar above the note textarea. */
.md-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  margin-bottom: 8px; padding: 4px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.md-btn {
  min-width: 30px; height: 28px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text); font-size: 13px; line-height: 1; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.md-btn:hover { background: var(--surface); border-color: var(--border); }
.md-btn:active { transform: translateY(1px); }
.md-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--border); }
/* Style the single-letter inline buttons to hint at their effect. */
.md-btn:nth-child(1) { font-weight: 700; }
.md-btn:nth-child(2) { font-style: italic; }
.md-btn:nth-child(3) { text-decoration: underline; }
.md-btn:nth-child(4) { text-decoration: line-through; }
.note-form-actions { display: flex; gap: 8px; margin-top: 8px; }

/* The notes column itself is just a transparent wrapper — every note is its
   own standalone white card sitting on the page background, so the list reads
   as separate blocks rather than one big panel. */
.detail .notes-col.panel {
  background: none; border: none; box-shadow: none;
  border-radius: 0; overflow: visible; padding: 0;
}

.note-list { display: flex; flex-direction: column; gap: 16px; }
.note-item {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 20px; background: var(--surface); box-shadow: var(--shadow);
}
/* Whole card opens the note as its own page. */
.note-clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s; }
.note-clickable:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.10), 0 2px 4px rgba(16, 24, 40, 0.06);
}
.note-clickable:active { transform: translateY(1px); }
.note-clickable a { cursor: pointer; }

/* Uniform list cards: every note body is the same fixed height and clips its
   overflow. Truncated cards fade out at the bottom and show a "read more" chip
   (the whole card is clickable). Scoped to .note-list so the single-note page
   and the off-screen measuring node keep their natural height. */
.note-list .note-body { position: relative; height: var(--note-body-max); overflow: hidden; }
.note-list .note-item.is-truncated .note-body::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--surface));
  pointer-events: none;
}
/* "read more" hint in the footer, pushed to the right (note-meta is flex). */
.note-list .note-item.is-truncated .note-meta::after {
  content: "Read more →"; margin-left: auto;
  color: var(--primary); font-weight: 600;
}

/* Single-note full page (VIEW_NOTE). */
.note-page-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.note-page-meta { display: flex; align-items: baseline; gap: 6px; font-size: 13px; color: var(--text-muted); }
.note-page-card { padding: 26px 30px; cursor: default; }
.note-page-card .note-body { font-size: 14px; line-height: 1.6; }
.note-edit-input { min-height: 340px; }
.note-page-title { font-weight: 600; font-size: 16px; color: var(--text); }
.is-hidden { display: none !important; }

/* Change history under the note. */
.note-history {
  margin-top: 20px; padding: 20px 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.note-history-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.note-history-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px;
}
.note-history-row::before {
  content: "✎"; color: var(--text-muted); font-size: 12px;
}
/* Each history entry opens that version read-only. Subtle row highlight rather
   than the card-style border/shadow used elsewhere for .note-clickable. */
.note-history-row.note-clickable { border-radius: 6px; padding-left: 8px; padding-right: 8px; }
.note-history-row.note-clickable:hover {
  border-color: var(--border); box-shadow: none; background: var(--bg);
}
.note-history-row.note-clickable::after {
  content: "→"; margin-left: auto; color: var(--text-muted);
  opacity: 0; transition: opacity 0.12s;
}
.note-history-row.note-clickable:hover::after { opacity: 1; }

/* Banner above a read-only past version (VIEW_NOTE_REVISION). */
.note-revision-banner {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 10px; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px;
}
.note-body { font-size: 13px; color: var(--text); word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.5; }
/* Redmine-formatted note content. Tight vertical rhythm so notes stay compact
   and a lot of text fits on screen, mirroring how Redmine renders. */
.note-body > *:first-child { margin-top: 0; }
.note-body > *:last-child { margin-bottom: 0; }
.note-body p { margin: 0 0 6px; }
.note-body h1, .note-body h2, .note-body h3,
.note-body h4, .note-body h5, .note-body h6 {
  margin: 10px 0 4px; line-height: 1.25; font-weight: 700; color: var(--text);
}
.note-body h1 { font-size: 16px; }
.note-body h2 { font-size: 15px; }
.note-body h3 { font-size: 13.5px; }
.note-body h4, .note-body h5, .note-body h6 { font-size: 13px; }
.note-body ul, .note-body ol { margin: 3px 0 6px; padding-left: 20px; }
.note-body li { margin: 1px 0; }
.note-body a { color: var(--primary); text-decoration: none; }
.note-body a:hover { text-decoration: underline; }
.note-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em; background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.note-body pre {
  margin: 8px 0; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  overflow-x: auto; line-height: 1.45;
}
.note-body pre code { background: none; border: 0; padding: 0; font-size: 0.9em; }
.note-body blockquote {
  margin: 8px 0; padding: 2px 12px; color: var(--text-muted);
  border-left: 3px solid var(--border);
}
.note-body hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.note-body ins { text-decoration: underline; }
.note-body del { text-decoration: line-through; color: var(--text-muted); }
/* Card footer: who made the last change and when. */
.note-meta {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.note-meta::before { content: "Last edited by"; }
.note-author { font-weight: 600; color: var(--text); }
.note-author::after { content: "·"; margin-left: 6px; color: var(--text-muted); font-weight: 400; }
.empty-notes { color: var(--text-muted); font-size: 14px; padding: 6px 2px; }

/* Creation meta shown under the note body on the note page (author + date). */
.note-page-meta {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.note-page-meta-label { color: var(--text-muted); }

.note-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px;
}
.pager-btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.pager-btn:hover { border-color: var(--primary); color: var(--primary); }
.pager-btn.disabled { opacity: 0.4; pointer-events: none; }
.pager-info { font-size: 13px; color: var(--text-muted); }

.detail-row {
  display: flex;
  gap: 28px;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: 1px solid #eef0f3;
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
  flex: 0 0 120px;
  color: #6b7280;
  font-size: 13px;
}

/* The value block (plain span or the .uuid-cell) is pushed to the right of the
   row and may shrink, so a wide value can never overflow the narrow column. */
.detail-row > :last-child {
  margin-left: auto;
  min-width: 0;
}
.detail-row span:last-child { font-size: 15px; }

.detail .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.clickable-row { cursor: pointer; }

/* Inline filter row inside the Employees panel: name search, target/team/manager
   dropdowns, a first-working-day range and an hours-per-week range. Wraps to as
   many rows as needed. */
.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 18px 24px 24px;
}
.list-filters input,
.list-filters select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
}
.list-filters .filter-search { flex: 1 1 240px; min-width: 200px; max-width: 380px; }
.list-filters select { cursor: pointer; }
.list-filters input:focus,
.list-filters select:focus { outline: none; border-color: var(--primary); }

/* A labelled range group (First day / Hours). */
.filter-range {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  background: var(--surface);
}
.filter-range input {
  border: none;
  padding: 5px 4px;
  border-radius: 6px;
}
.filter-range input:focus { outline: none; }
.filter-label { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.filter-dash { color: var(--text-muted); }
.filter-num { width: 60px; }

/* Reset flows right after the last filter (no auto-margin jamming it to the
   panel edge), with a touch of separation. */
.list-filters .filter-reset { margin-left: 4px; }

/* Team detail: "Team members" heading with its add-member (+) button. */
.members-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 8px;
}

/* ---- Add-member search modal --------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
}
.modal-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 22px 24px;
  width: min(440px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-sub { font-size: 13px; color: var(--text-muted); margin-top: -8px; }
.modal-card input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}
.candidate-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.candidate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.candidate-item:hover { background: var(--primary-soft); }
.candidate-name { font-weight: 500; }
.candidate-team { font-size: 12px; color: var(--text-muted); }

/* ---- Custom date picker + calendar (components/DatePicker + Calendar) ---- */

.date-picker { position: relative; display: inline-flex; }

.date-picker-field {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px;
  background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; user-select: none;
  transition: border-color 0.15s;
}
.date-picker-field:hover { border-color: var(--primary); }
.date-picker-text { font-size: 14px; }
.date-picker-text--empty { color: var(--text-muted); }
.date-picker-clear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 2px;
  border-radius: 50%;
  color: var(--text-muted); font-size: 14px; line-height: 1;
}
.date-picker-clear:hover { background: var(--primary-soft); color: var(--primary); }
.date-picker-cal-icon { font-size: 14px; }

/* Inside the filter chip the parent already draws the border. */
.filter-range .date-picker-field { border: none; padding: 5px 4px; background: transparent; }
.filter-range .date-picker-field:hover { border-color: transparent; }

/* In a form column the field should fill the width, like the other inputs. */
.form-group .date-picker,
.form-group .date-picker-field { width: 100%; box-sizing: border-box; }

.date-picker-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: transparent; border: none; padding: 0; cursor: default;
}
/* Anchor to the field's right edge so the 280px popup grows leftward and stays
   inside the viewport (the date fields sit near the right edge of the bar). */
.date-picker-popup { position: absolute; top: calc(100% + 6px); right: 0; z-index: 41; }

.cal {
  --cal-accent: var(--primary);
  --cal-fg:     var(--text);
  --cal-muted:  var(--text-muted);
  --cal-bg:     var(--surface);
  --cal-hover:  var(--primary-soft);

  box-sizing: border-box;
  width: 280px; padding: 12px;
  background: var(--cal-bg); color: var(--cal-fg);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
  font-family: inherit; user-select: none;
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title {
  font-weight: 600; font-size: 15px;
  border: none; background: transparent; color: var(--cal-fg);
  padding: 4px 10px; border-radius: 8px; cursor: pointer;
}
.cal-title:hover { background: var(--cal-hover); }

/* Month / year scrollable dropdowns in the calendar header. */
.cal-selects { display: flex; align-items: center; gap: 6px; }
.cal-select { position: relative; }
.cal-select-trigger {
  font-weight: 600; font-size: 15px;
  border: none; background: transparent; color: var(--cal-fg);
  padding: 4px 8px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.cal-select-trigger:hover { background: var(--cal-hover); }
.cal-dropdown {
  position: absolute; top: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  z-index: 5;
  min-width: 120px; max-height: 220px; overflow-y: auto;
  padding: 4px;
  background: var(--cal-bg); color: var(--cal-fg);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
  display: flex; flex-direction: column;
}
.cal-dropdown--years { min-width: 96px; }
.cal-option {
  padding: 7px 12px; text-align: center;
  border: none; background: transparent; color: var(--cal-fg);
  border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.cal-option:hover { background: var(--cal-hover); }
.cal-option--selected,
.cal-option--selected:hover { background: var(--cal-accent); color: #fff; }
.cal-nav {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--cal-fg);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.cal-nav:hover { background: var(--cal-hover); }
.cal-weekdays,
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-weekdays { margin-bottom: 4px; }
.cal-weekdays span {
  padding: 4px 0; text-align: center;
  font-size: 11px; font-weight: 600; color: var(--cal-muted);
}
.cal-day {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1;
  border: none; border-radius: 8px;
  background: transparent; color: var(--cal-fg);
  font-size: 13px; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.cal-day:hover { background: var(--cal-hover); }
.cal-day--muted { color: var(--cal-muted); }
.cal-day--today { box-shadow: inset 0 0 0 1.5px var(--cal-accent); font-weight: 600; }
.cal-day--selected,
.cal-day--selected:hover { background: var(--cal-accent); color: #fff; }
.cal-footer { display: flex; justify-content: flex-end; margin-top: 8px; }
.cal-today {
  padding: 6px 10px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--cal-accent);
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.cal-today:hover { background: var(--cal-hover); }

.date-picker-hidden { display: none; }

/* ---- Detail page tabs (Notes | Work time policy) ------------------------- */
.detail-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  appearance: none; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--text-muted);
  padding: 8px 14px; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* The notes-header now holds only the add-note pencil — push it to the right. */
.notes-header { justify-content: flex-end; }

/* ---- Work time policy tab ------------------------------------------------ */
.wtp-panel {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 22px; background: var(--surface); box-shadow: var(--shadow);
}
.wtp-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.wtp-badge {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  padding: 4px 11px; border-radius: 999px; color: #fff;
}
.wtp-badge-pass    { background: var(--success); }
.wtp-badge-warning { background: var(--warning); }
.wtp-badge-fail    { background: var(--danger); }
.wtp-category {
  font-size: 12.5px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px;
}
.wtp-period { margin-left: auto; font-size: 13px; color: var(--text-muted); }
.wtp-warn {
  font-size: 13px; color: #92620a;
  background: #fff8ec; border: 1px solid #f5deb0;
  border-radius: 8px; padding: 8px 12px; margin-bottom: 16px;
}

.wtp-totals { display: flex; gap: 10px; margin-bottom: 20px; }
.wtp-total {
  flex: 1 1 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.wtp-total-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.wtp-total-val  { font-size: 22px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.wtp-total-unit { font-size: 13px; color: var(--text-muted); margin-left: 3px; }

.wtp-months { display: flex; flex-direction: column; gap: 8px; }
.wtp-month {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--border);
  border-left: 3px solid var(--neutral); border-radius: 10px;
  background: var(--surface-2);
}
.wtp-month-met  { border-left-color: var(--success); }
.wtp-month-miss { border-left-color: var(--danger); }
.wtp-month-na   { border-left-color: var(--border); opacity: 0.65; }
.wtp-month-name  { font-weight: 600; flex: 0 0 92px; }
.wtp-month-hours { font-variant-numeric: tabular-nums; }
.wtp-month-ann   { margin-left: auto; font-size: 12px; color: var(--text-muted); }

.wtp-error {
  font-size: 14px; color: #b42318;
  background: #fef3f2; border: 1px solid #fca5a5;
  border-radius: 10px; padding: 14px 16px;
}

/* ---- Work time policy column (employee list) ----------------------------- */
.wtp-cell { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }
.wtp-cell-pass  { color: var(--success); font-weight: 600; }
.wtp-cell-warn  { color: var(--warning); font-weight: 600; }
.wtp-cell-fail  { color: var(--danger);  font-weight: 600; }
.wtp-cell-none  { color: var(--text-muted); }
.wtp-cell-muted { color: var(--neutral); }

/* ---- Login layout helpers --------------------------------------------- */
.login-step    { display: flex; flex-direction: column; gap: 16px; }
.login-actions { display: flex; gap: 10px; }
.login-actions .btn-primary   { flex: 1; }
.login-actions .btn-secondary { margin-left: 0; }

/* ---- Segmented one-time-code input ------------------------------------ */
/* Six visible cells with a single transparent <input> overlaid on top, so
   native typing / paste / backspace keep working while the boxes just mirror
   the current value. */
.otp-field { position: relative; }
.otp-cells {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.otp-cell {
  display: flex; align-items: center; justify-content: center;
  height: 52px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2, #fafbfc);
  font-size: 24px; font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.otp-cell--filled {
  border-color: var(--primary);
  background: var(--surface);
}
.otp-cell--active {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.otp-cell--active::after {
  content: "";
  width: 2px; height: 24px;
  background: var(--primary);
  border-radius: 1px;
  animation: otp-caret 1s steps(1) infinite;
}
@keyframes otp-caret { 50% { opacity: 0; } }

.otp-field .otp-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  letter-spacing: 0;
  cursor: text;
  z-index: 2;
}
.otp-field .otp-input:focus { outline: none; }

/* ---- Drop the native dropdown arrow from every select ----------------- */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: none;
}
select::-ms-expand { display: none; }
