/* workbook.css - Workbook tab (planner.digimax.mu). All selectors are prefixed .wb */
.wb-root {
  --wb-red: #E3262E; --wb-ink: #161616; --wb-line: #E3E5E8; --wb-muted: #6B7280;
  --wb-bg: #fff; --wb-soft: #F6F7F8; --wb-sel: #FDECEC;
  display: flex; flex-direction: column; gap: 10px; min-width: 0; color: var(--wb-ink); font-family: inherit;
}
.wb-root [hidden] { display: none !important; }
.wb-root :focus-visible { outline: 2px solid var(--wb-red); outline-offset: 1px; }
.wb-muted { color: var(--wb-muted); }
.wb-loading, .wb-empty { color: var(--wb-muted); padding: 16px 4px; }
.wb-error { color: #B42318; font-size: 13px; }

/* buttons + inputs */
.wb-btn {
  font: inherit; font-size: 13px; border: 1px solid var(--wb-line); background: #fff; color: var(--wb-ink);
  padding: 5px 11px; border-radius: 6px; cursor: pointer; min-height: 30px; white-space: nowrap;
}
.wb-btn:hover { border-color: #C9CDD2; background: var(--wb-soft); }
.wb-btn-primary { background: var(--wb-red); border-color: var(--wb-red); color: #fff; }
.wb-btn-primary:hover { background: #C81F27; border-color: #C81F27; }
.wb-link { font: inherit; font-size: 13px; background: none; border: 0; color: var(--wb-muted); text-decoration: underline; cursor: pointer; padding: 4px; }
.wb-root input[type=text], .wb-root input[type=search], .wb-root input[type=date], .wb-root input[type=number],
.wb-root input:not([type]), .wb-root select, .wb-root textarea {
  font: inherit; font-size: 13px; color: var(--wb-ink); border: 1px solid var(--wb-line); border-radius: 6px;
  padding: 4px 6px; background: #fff; min-height: 30px; box-sizing: border-box;
}

/* toolbar */
.wb-toolbar { display: flex; flex-direction: column; gap: 8px; }
.wb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wb-chip {
  font: inherit; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--wb-line); background: #fff; color: var(--wb-ink); border-radius: 999px; padding: 4px 10px; min-height: 30px;
}
.wb-chip b { font-weight: 600; color: var(--wb-muted); }
.wb-chip .wb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.wb-chip.is-on { background: var(--c); border-color: var(--c); color: #fff; }
.wb-chip.is-on b { color: #fff; }
.wb-chip.is-on .wb-dot { background: #fff; }
.wb-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wb-search { min-width: 180px; flex: 0 1 260px; }
.wb-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--wb-muted); }
.wb-spacer { flex: 1; }
.wb-msg { background: #FEF3F2; color: #B42318; border: 1px solid #FECDCA; border-radius: 6px; padding: 6px 10px; font-size: 13px; }

/* bulk bar */
.wb-bulk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; font-size: 13px;
  background: var(--wb-ink); color: #fff; border-radius: 8px;
}
.wb-bulk label { display: inline-flex; align-items: center; gap: 6px; }
.wb-bulk .wb-link { color: #ddd; }
.wb-bulknote { min-width: 160px; flex: 1 1 200px; }

/* layout */
.wb-main { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
@media (max-width: 1100px) { .wb-main { grid-template-columns: minmax(0, 1fr); } }

/* table */
.wb-tablewrap {
  overflow: auto; max-height: calc(100vh - 230px); min-height: 240px;
  border: 1px solid var(--wb-line); border-radius: 8px; background: var(--wb-bg);
  -webkit-overflow-scrolling: touch;
}
.wb-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.wb-table th, .wb-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--wb-line); text-align: left; vertical-align: middle;
  white-space: nowrap; background: var(--wb-bg);
}
.wb-table thead th {
  position: sticky; top: 0; z-index: 3; background: var(--wb-soft); font-weight: 600; font-size: 12px;
  color: var(--wb-muted); text-transform: none; border-bottom: 1px solid #D5D8DC;
}
/* sticky first columns: checkbox + code */
.wb-c-sel { position: sticky; left: 0; z-index: 2; width: 34px; min-width: 34px; max-width: 34px; text-align: center !important; padding: 6px 4px !important; }
.wb-c-code { position: sticky; left: 34px; z-index: 2; min-width: 64px; box-shadow: 1px 0 0 var(--wb-line); }
.wb-table thead .wb-c-sel, .wb-table thead .wb-c-code { z-index: 4; }
.wb-c-name { min-width: 240px; white-space: normal !important; }
.wb-c-notes { min-width: 200px; max-width: 360px; white-space: normal !important; }
.wb-num { text-align: right !important; font-variant-numeric: tabular-nums; }
.wb-date { font-variant-numeric: tabular-nums; }
.wb-last { color: var(--wb-muted); font-size: 12px; }

.wb-code {
  font: inherit; font-weight: 600; background: none; border: 0; color: var(--wb-red); cursor: pointer; padding: 2px 0;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 2px;
}
.wb-code:hover { text-decoration-color: currentColor; }

.wb-editable { cursor: text; }
.wb-editable:hover { box-shadow: inset 0 0 0 1px #D5D8DC; }
.wb-input { width: 100%; min-width: 80px; }
textarea.wb-input { min-width: 200px; resize: vertical; }

.wb-row:hover td { background: #FAFAFB; }
.wb-row.is-selected td { background: var(--wb-sel); }
/* shared selection (store.selectedTaskId): tint over white so sticky cells stay opaque */
.wb-row.is-current td, .wb-row.is-current:hover td {
  background: linear-gradient(rgba(227,38,46,.08), rgba(227,38,46,.08)), #fff;
}
.wb-row.is-current.is-selected td { background: linear-gradient(rgba(227,38,46,.08), rgba(227,38,46,.08)), var(--wb-sel); }
.wb-row { scroll-margin-top: 40px; }
.wb-row.is-current .wb-c-sel { box-shadow: inset 3px 0 0 #E3262E; }
.wb-tablewrap:focus { outline: none; }
.wb-tablewrap:focus-visible { outline: 2px solid var(--wb-red); outline-offset: 1px; }
.wb-row.is-cancelled .wb-c-name { text-decoration: line-through; color: var(--wb-muted); }

/* group rows */
.wb-group td { background: var(--wb-soft); font-weight: 600; }
.wb-grouphead { white-space: normal !important; }
.wb-gh { position: sticky; left: 42px; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 0; max-width: calc(100vw - 90px); }
.wb-twisty { font: inherit; background: none; border: 0; cursor: pointer; width: 22px; padding: 0; color: var(--wb-ink); }
.wb-gname { margin-right: 10px; }
.wb-gmeta { font-weight: 400; font-size: 12px; color: var(--wb-muted); margin-right: 10px; }
.wb-gbar { display: inline-block; width: 90px; height: 6px; border-radius: 3px; background: #E3E5E8; overflow: hidden; }
.wb-gbar i { display: block; height: 100%; background: #2E8B57; }

/* status select / pill */
.wb-status, .wb-pill {
  background: var(--c) !important; color: #fff !important; border-color: var(--c) !important; font-weight: 500;
  border-radius: 999px !important; padding: 3px 8px !important; min-height: 26px !important;
}
.wb-status option { background: #fff; color: var(--wb-ink); }
.wb-pill { display: inline-block; font-size: 12px; }
.wb-status.is-frozen, .wb-pill.is-frozen {
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.28) 0 4px, transparent 4px 8px) !important;
}

/* progress */
.wb-prog { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: #E3E5E8; overflow: hidden; margin-right: 6px; vertical-align: middle; }
.wb-prog i { display: block; height: 100%; }

/* status note row */
.wb-statusnote td { background: #FFF8EC !important; white-space: normal !important; }
.wb-sn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: sticky; left: 42px; max-width: min(100%, 90vw); }
.wb-statusnote input { min-width: 200px; flex: 1 1 240px; max-width: 420px; }

/* add form */
.wb-addrow td { background: #FFF8F8 !important; white-space: normal !important; }
.wb-addform { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; position: sticky; left: 8px; max-width: min(100%, 92vw); }
.wb-addform label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--wb-muted); }
.wb-addform .wb-f-name { flex: 1 1 220px; }
.wb-addform .wb-f-name input { width: 100%; }
.wb-addform .wb-f-notes { flex: 1 1 200px; }
.wb-addform .wb-f-notes input { width: 100%; }
.wb-addform .wb-f-check { flex-direction: row; align-items: center; min-height: 30px; color: var(--wb-ink); }
.wb-addform select[name=dep] { max-width: 240px; }
.wb-f-actions { display: flex; align-items: center; gap: 8px; }

/* activity */
.wb-activity { border: 1px solid var(--wb-line); border-radius: 8px; background: #fff; font-size: 12.5px; max-height: calc(100vh - 230px); overflow: auto; }
.wb-activity summary { cursor: pointer; padding: 10px 12px; font-weight: 600; position: sticky; top: 0; background: #fff; }
.wb-activity ol { list-style: none; margin: 0; padding: 0 12px 10px; }
.wb-activity li { padding: 8px 0; border-top: 1px solid var(--wb-line); }
.wb-a-meta { color: var(--wb-muted); font-size: 11.5px; }
.wb-a-task { font-weight: 500; }
.wb-a-what { overflow-wrap: anywhere; }
.wb-a-note { font-style: italic; color: #444; }
.wb-activity p { padding: 0 12px 10px; margin: 0; }

/* fallback history (when drawer.js is unavailable) */
.wb-history {
  position: fixed; right: 16px; bottom: 16px; width: min(420px, calc(100vw - 32px)); max-height: 60vh; overflow: auto;
  background: #fff; border: 1px solid var(--wb-line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15);
  padding: 12px 14px; z-index: 50; font-size: 13px;
}
.wb-history-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.wb-history ol { margin: 0; padding-left: 18px; }

@media (max-width: 640px) {
  .wb-search { flex: 1 1 100%; }
  .wb-tablewrap { max-height: 70vh; }
}

/* ---------- v0.2: view switch, people, board (Kanban) ---------- */
.wb-seg { display: inline-flex; }
.wb-seg button {
  font: inherit; font-size: 13px; border: 1px solid var(--wb-line); background: #fff; color: var(--wb-ink);
  padding: 5px 12px; min-height: 30px; cursor: pointer; margin-left: -1px;
}
.wb-seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.wb-seg button:last-child { border-radius: 0 6px 6px 0; }
.wb-seg button[aria-pressed="true"] { background: var(--wb-ink); border-color: var(--wb-ink); color: #fff; position: relative; }

.kb-people { display: inline-flex; }
.kb-people i {
  font-style: normal; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; width: 22px; height: 22px;
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: #EEF0F3; color: var(--wb-ink); border: 2px solid #fff; margin-left: -5px;
}
.kb-people i:first-child { margin-left: 0; }
.wb-people { min-width: 64px; }

.kb-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kb-hint { font-size: 12px; margin: 0; }
.kb-board {
  display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 6px;
  -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.kb-lane {
  flex: 0 0 272px; display: flex; flex-direction: column; min-width: 0;
  background: var(--wb-soft); border: 1px solid var(--wb-line); border-top: 3px solid var(--c); border-radius: 8px;
  max-height: calc(100vh - 250px);
}
.kb-lane.is-frozen { background-image: repeating-linear-gradient(135deg, rgba(111,183,214,.10) 0 6px, transparent 6px 12px); }
.kb-lane.is-over { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 35%, transparent); }
.kb-lane-head { display: flex; align-items: center; gap: 7px; padding: 8px 10px; font-weight: 600; font-size: 13px; }
.kb-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.kb-lane-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-count { font-size: 12px; color: var(--wb-muted); background: #fff; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--wb-line); }
.kb-lane-toggle { font: inherit; background: none; border: 0; cursor: pointer; padding: 2px 4px; color: var(--wb-ink); }
.kb-lane.is-collapsed { flex: 0 0 44px; max-height: 260px; }
.kb-lane.is-collapsed .kb-lane-head { flex-direction: column; padding: 8px 4px; gap: 8px; }
.kb-lane.is-collapsed .kb-lane-name { writing-mode: vertical-rl; transform: rotate(180deg); overflow: visible; }
.kb-lane.is-collapsed .kb-lane-toggle { order: -1; }

.kb-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; min-height: 56px; display: flex; flex-direction: column; gap: 8px; }
.kb-list:empty::before { content: "No tasks"; color: var(--wb-muted); font-size: 12px; text-align: center; padding: 18px 0; border: 1px dashed var(--wb-line); border-radius: 8px; }
.kb-card {
  background: #fff; border: 1px solid var(--wb-line); border-radius: 8px; padding: 8px 10px 9px; font-size: 13px;
  display: flex; flex-direction: column; gap: 6px; cursor: default; position: relative;
  box-shadow: 0 1px 2px rgba(16,24,40,.05); -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  scroll-margin: 12px;
}
.kb-card.is-draggable { cursor: grab; }
.kb-card:hover { border-color: #C9CDD2; }
.kb-card.is-current { background: linear-gradient(rgba(227,38,46,.08), rgba(227,38,46,.08)), #fff; box-shadow: inset 3px 0 0 #E3262E, 0 1px 2px rgba(16,24,40,.05); border-color: #F3B4B6; }
.kb-card.is-dragging { opacity: .35; }
.kb-card.is-cancelled .kb-name { text-decoration: line-through; color: var(--wb-muted); }
.kb-card.is-pending { cursor: default; user-select: text; -webkit-user-select: text; }
.kb-ghost { box-shadow: 0 12px 28px rgba(0,0,0,.22); transform: rotate(1.5deg); opacity: .96; cursor: grabbing; }
.kb-dragging, .kb-dragging * { cursor: grabbing !important; }
.kb-marker { height: 4px; border-radius: 2px; background: var(--wb-red); margin: -2px 0; list-style: none; }
.kb-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kb-code { font: inherit; font-weight: 700; font-size: 12.5px; background: none; border: 0; color: var(--wb-red); padding: 0; cursor: pointer; }
.kb-code:hover { text-decoration: underline; }
.kb-group {
  font-size: 11px; color: var(--wb-muted); background: var(--wb-soft); border: 1px solid var(--wb-line); border-radius: 999px;
  padding: 1px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 170px;
}
.kb-name { font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.kb-ms { color: var(--wb-ink); }
.kb-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--wb-muted); min-height: 22px; }
.kb-end { font-variant-numeric: tabular-nums; }
.kb-end.is-late { color: #C81F27; font-weight: 600; }
.kb-comments { display: inline-flex; align-items: center; gap: 3px; }
.kb-meta .kb-people { margin-left: auto; }
.kb-prog { height: 4px; border-radius: 2px; background: #E3E5E8; overflow: hidden; }
.kb-prog i { display: block; height: 100%; }
.kb-note { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px dashed var(--wb-line); font-size: 12.5px; }
.kb-note input { width: 100%; }
.kb-note-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

@media (max-width: 640px) {
  .kb-board { scroll-snap-type: x mandatory; scroll-padding: 0 16px; }
  .kb-lane { flex-basis: min(84vw, 300px); scroll-snap-align: start; max-height: 70vh; }
  .kb-lane.is-collapsed { flex-basis: 44px; }
}

/* free autoscroll while dragging (mandatory snap would fight it) */
.kb-dragging .kb-board { scroll-snap-type: none; }
