/* Daily Flow 2.0
   Context-first row hierarchy over the existing WorkItem engine. */

.work-table-v2 {
  table-layout: fixed;
  width: 100%;
  min-width: 900px;
}

.work-table-v2 .work-v2-col-context {
  width: 21%;
}

.work-table-v2 .work-v2-col-task {
  width: auto;
}

.work-table-v2 .work-v2-col-status {
  width: 12%;
}

.work-table-v2 .work-v2-col-assignee {
  width: 11%;
}

.work-table-v2 .work-v2-col-day {
  width: 9%;
}

.work-table-v2 .work-v2-col-complete {
  width: 12%;
}

.work-table-v2 th,
.work-table-v2 td {
  height: 76px;
}

.work-table-v2 th {
  padding-left: 12px;
  padding-right: 12px;
}

.work-table-v2 .work-v2-context-cell,
.work-table-v2 .work-v2-task-cell {
  padding: 10px 14px;
}

.work-v2-context {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: center;
}

.work-v2-origin {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f3f5f8;
  color: #697586;
  font-size: 9px;
  font-weight: 780;
  line-height: 1;
  white-space: nowrap;
}

.work-v2-origin::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
}

.work-v2-origin--service {
  background: #eef4ff;
  color: #4467b6;
}

.work-v2-origin--crm {
  background: #f2efff;
  color: #6a55b7;
}

.work-v2-origin--operation {
  background: #f3f5f8;
  color: #667085;
}

.work-v2-context .work-cell-primary {
  margin-top: 1px;
  font-size: 13.5px;
}

.work-v2-context .work-cell-secondary {
  overflow: hidden;
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-v2-task {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: center;
}

.work-v2-task-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.work-v2-task-copy .work-cell-primary {
  overflow: hidden;
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-v2-task-copy .work-cell-secondary {
  overflow: hidden;
  max-width: 100%;
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-v2-task-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.work-v2-meta-action {
  appearance: none;
  flex: 0 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.work-v2-meta-action:hover {
  background: #f5f7fa;
}

.work-v2-task-meta .work-chip,
.work-v2-task-meta .pill {
  min-height: 22px;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 9.5px;
}

.work-v2-task-meta .work-update-mark {
  flex: 0 0 28px;
  width: 28px;
  min-width: 28px;
  height: 28px;
}

.work-table-v2 .work-meta-rail,
.work-table-v2 .work-day,
.work-table-v2 .work-complete-btn {
  height: 76px;
  min-height: 76px;
}

.work-table-v2 .work-meta-cell .pill {
  font-size: 10.5px;
}

.work-table-v2 .work-avatar {
  width: 27px;
  height: 27px;
  min-width: 27px;
}

.work-table-v2 .work-day {
  font-size: 11px;
}

.work-table-v2 .work-complete-btn {
  gap: 6px;
}

.work-table-v2 .work-complete-btn span:last-child {
  font-size: 11px;
}

.work-row-v2:hover {
  background: color-mix(
    in srgb,
    var(--soft) 76%,
    transparent
  );
}

html[data-theme="dark"] .work-v2-origin {
  background: #202936;
  color: #aab4c2;
}

html[data-theme="dark"] .work-v2-origin--service {
  background: #182840;
  color: #9dbaff;
}

html[data-theme="dark"] .work-v2-origin--crm {
  background: #28223d;
  color: #c0b2ff;
}

html[data-theme="dark"] .work-v2-meta-action:hover {
  background: #1e2936;
}

@media (min-width: 1100px) {
  .work-zone-body {
    overflow-x: hidden;
  }

  .work-table-v2 {
    min-width: 900px;
  }
}

@media (max-width: 1099px) {
  .work-zone-body {
    overflow-x: auto;
  }

  .work-table-v2 {
    min-width: 900px;
  }
}

@media (max-width: 760px) {
  .work-table-v2 {
    min-width: 900px;
  }
}


/* Daily Flow 2.0 · Time-first grouping and simpler attention model. */
.flow-attention {
  min-height: 42px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.flow-attention-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.flow-attention-label b {
  color: var(--ink);
  font-size: 10.5px;
}

.flow-attention-item {
  appearance: none;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.flow-attention-item span {
  font-size: 10.5px;
  white-space: nowrap;
}

.flow-attention-item b {
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.flow-attention-item:hover,
.flow-attention-item.active {
  background: var(--soft);
}

.flow-attention-item.warning b {
  color: #d97706;
}

.flow-attention-item.positive b {
  color: #2a9b68;
}

.flow-attention .flow-insights-trigger {
  margin-left: auto;
  border-left: 0;
}

.flow-commandbar-v2 {
  overflow: visible;
}

.flow-group-menu {
  position: relative;
}

.flow-group-menu > summary {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  user-select: none;
}

.flow-group-menu > summary::-webkit-details-marker {
  display: none;
}

.flow-group-menu > summary:hover,
.flow-group-menu[open] > summary {
  background: var(--soft);
  color: var(--ink);
}

.flow-group-menu > summary b {
  color: var(--ink);
  font-size: 10.5px;
}

.flow-group-menu > summary i {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.flow-group-popover {
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 40;
  width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 42px rgba(16, 24, 40, .14);
}

.flow-group-popover button {
  appearance: none;
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.flow-group-popover button:hover {
  background: var(--soft);
  color: var(--ink);
}

.flow-group-popover button.active {
  color: var(--ink);
  font-weight: 700;
}

.flow-group-popover button b {
  color: #5267e8;
  font-size: 11px;
}

.flow-board-v2 {
  gap: 10px;
}

.flow-group-card.warning {
  border-color: color-mix(
    in srgb,
    #d97706 28%,
    var(--line)
  );
}

.flow-group-card.warning .work-zone-toggle {
  background: color-mix(
    in srgb,
    #d97706 5%,
    var(--panel)
  );
}

.work-table-v2 .work-day {
  display: grid !important;
  align-content: center;
  justify-items: center;
  gap: 2px;
  line-height: 1.15;
}

.work-table-v2 .work-day strong {
  color: inherit;
  font-size: 10.5px;
  font-weight: 740;
  white-space: nowrap;
}

.work-table-v2 .work-day small {
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 560;
  white-space: nowrap;
}

.work-table-v2 .work-day.carryover strong {
  color: #d97706;
}

.work-table-v2 .work-day.carryover small {
  color: color-mix(
    in srgb,
    #d97706 74%,
    var(--muted)
  );
}

html[data-theme="dark"] .flow-attention,
html[data-theme="dark"] .flow-group-popover {
  background: #151e29;
  border-color: #2c394a;
}

html[data-theme="dark"] .flow-attention-item:hover,
html[data-theme="dark"] .flow-attention-item.active,
html[data-theme="dark"] .flow-group-menu > summary:hover,
html[data-theme="dark"] .flow-group-menu[open] > summary,
html[data-theme="dark"] .flow-group-popover button:hover {
  background: #1e2936;
}

@media (max-width: 1050px) {
  .flow-attention-label {
    display: none;
  }

  .flow-attention-item {
    padding: 0 10px;
  }

  .flow-attention-item span {
    display: none;
  }

  .flow-command-tools {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .flow-group-popover {
    position: fixed;
    right: 12px;
    top: 150px;
    width: 210px;
  }
}


/* Daily Flow 2.0 visual acceptance refinement */
.flow-group-card .work-zone-toggle {
  min-height: 42px;
  padding: 0 14px;
}

.flow-group-card .zone-caret {
  transform: scale(.9);
}

.flow-group-card .zone-dot {
  width: 5px;
  height: 24px;
}

.flow-group-card .zone-count {
  font-size: 10.5px;
}

.work-table-v2 thead th {
  height: 50px;
}

.work-table-v2 .work-day {
  display: flex !important;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.work-table-v2 .work-day strong {
  font-size: 11px;
  font-weight: 720;
}

.work-table-v2 .work-day small {
  display: none;
}

.work-table-v2 .work-day.carryover strong {
  color: #d97706;
}

/* Center the work detail as a focused workspace instead of a right drawer. */
.work-drawer {
  display: grid !important;
  place-items: center;
  grid-template-columns: 1fr !important;
  padding: 24px;
  box-sizing: border-box;
}

.work-drawer.hidden {
  display: none !important;
}

.work-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .28);
  backdrop-filter: blur(3px);
}

.work-drawer-panel {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100vw - 56px));
  height: min(88vh, 900px);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
}

.work-drawer-close {
  background: var(--panel);
  border-color: var(--line);
  color: var(--muted);
}

/* Dark-mode support for Daily Flow labels and inline editors. */
html[data-theme="dark"] .daily-open,
html[data-theme="dark"] .daily-cancelled,
html[data-theme="dark"] .priority-low {
  background: #202936;
  color: #c7d0dc;
}

html[data-theme="dark"] .daily-assigned,
html[data-theme="dark"] .priority-normal {
  background: #1d2d48;
  color: #9dbaff;
}

html[data-theme="dark"] .daily-in-progress,
html[data-theme="dark"] .daily-completed {
  background: #173226;
  color: #8ee0b4;
}

html[data-theme="dark"] .daily-waiting,
html[data-theme="dark"] .priority-high {
  background: #3a2a18;
  color: #f0b56a;
}

html[data-theme="dark"] .priority-critical {
  background: #3b2026;
  color: #f39aa5;
}

html[data-theme="dark"] .work-chip {
  background: color-mix(
    in srgb,
    var(--chip) 24%,
    #151e29
  );
  color: color-mix(
    in srgb,
    var(--chip) 48%,
    #ffffff
  );
}

html[data-theme="dark"] .work-inline-popover {
  background: #151e29;
  border-color: #344154;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .45);
}

html[data-theme="dark"] .work-inline-title {
  color: #edf2f7;
  border-bottom-color: #2d3949;
}

html[data-theme="dark"] .work-inline-title small {
  color: #8f9bad;
}

html[data-theme="dark"] .work-inline-option {
  color: #c3ccda;
}

html[data-theme="dark"] .work-inline-option:hover,
html[data-theme="dark"] .work-inline-person:hover {
  background: #1e2936;
}

html[data-theme="dark"] .work-inline-option.active {
  background: #213452;
  color: #a9c4ff;
}

html[data-theme="dark"] .work-inline-people {
  background: transparent;
}

html[data-theme="dark"] .work-inline-person {
  color: #d8e0eb;
}

html[data-theme="dark"] .work-inline-person small {
  color: #8f9bad;
}

html[data-theme="dark"] .work-inline-actions {
  border-top-color: #2d3949;
}

html[data-theme="dark"] .work-avatar-empty {
  background: #18212d;
  border-color: #506078;
  color: #aab5c4;
}

html[data-theme="dark"] .work-drawer-panel {
  background: #151e29;
  border-color: #344154;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .5);
}

html[data-theme="dark"] .work-drawer-close {
  background: #18212d;
  border-color: #344154;
  color: #b7c1cf;
}

@media (max-width: 760px) {
  .work-drawer {
    padding: 0 !important;
  }

  .work-drawer-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
  }
}


/* Daily Flow horizontal row rhythm */
.flow-group-card .work-zone-toggle {
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
}

.flow-group-card .zone-dot {
  height: 20px;
}

.work-table-v2 thead th {
  height: 42px;
}

.work-table-v2 th,
.work-table-v2 td {
  height: 60px;
}

.work-table-v2 .work-meta-rail,
.work-table-v2 .work-day,
.work-table-v2 .work-complete-btn {
  height: 60px;
  min-height: 60px;
}

.work-table-v2 .work-v2-context-cell,
.work-table-v2 .work-v2-task-cell {
  padding-top: 8px;
  padding-bottom: 8px;
}

.work-v2-context-line,
.work-v2-task-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
}

.work-v2-context-line .work-cell-primary,
.work-v2-task-line .work-cell-primary {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-v2-context-line .work-cell-primary {
  max-width: 42%;
  font-size: 13px;
}

.work-v2-task-line .work-cell-primary {
  max-width: 52%;
  font-size: 13px;
}

.work-v2-origin {
  flex: 0 0 auto;
  min-height: 20px;
}

.work-v2-context-detail {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-v2-task-meta {
  flex: 0 0 auto;
  gap: 5px;
  overflow: visible;
  white-space: nowrap;
}

.work-v2-task-meta .work-chip,
.work-v2-task-meta .pill {
  min-height: 20px;
  padding-top: 2px;
  padding-bottom: 2px;
  font-size: 9px;
  white-space: nowrap;
}

.work-v2-task-meta .work-update-mark {
  flex-basis: 24px;
  width: 24px;
  min-width: 24px;
  height: 24px;
}

.work-v2-task-detail {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-v2-context,
.work-v2-task,
.work-v2-task-copy {
  display: contents;
}

@media (max-width: 1180px) {
  .work-table-v2 {
    min-width: 980px;
  }

  .work-v2-context-line .work-cell-primary {
    max-width: 38%;
  }

  .work-v2-task-line .work-cell-primary {
    max-width: 46%;
  }
}


/* Daily Flow sticky primary columns
   Primary context stays readable; operational metadata scrolls horizontally. */

.work-zone-body {
  overflow-x: auto !important;
  overflow-y: visible;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.work-table-v2 {
  --flow-context-width: 320px;
  --flow-task-width: 560px;
  table-layout: fixed;
  width: 1430px;
  min-width: 1430px;
}

.work-table-v2 .work-v2-col-context {
  width: var(--flow-context-width);
}

.work-table-v2 .work-v2-col-task {
  width: var(--flow-task-width);
}

.work-table-v2 .work-v2-col-status {
  width: 150px;
}

.work-table-v2 .work-v2-col-assignee {
  width: 130px;
}

.work-table-v2 .work-v2-col-day {
  width: 120px;
}

.work-table-v2 .work-v2-col-complete {
  width: 150px;
}

/* Freeze the two meaning-bearing columns. */
.work-table-v2 thead th:nth-child(1),
.work-table-v2 tbody td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--panel);
}

.work-table-v2 thead th:nth-child(2),
.work-table-v2 tbody td:nth-child(2) {
  position: sticky;
  left: var(--flow-context-width);
  z-index: 5;
  background: var(--panel);
}

.work-table-v2 thead th:nth-child(1),
.work-table-v2 thead th:nth-child(2) {
  z-index: 7;
  background: var(--panel);
}

/* Quiet edge between fixed meaning and scrollable operations. */
.work-table-v2 thead th:nth-child(2)::after,
.work-table-v2 tbody td:nth-child(2)::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;
  width: 1px;
  background: var(--line);
  box-shadow: 10px 0 18px -14px rgba(15, 23, 42, .55);
  pointer-events: none;
}

.work-table-v2 tbody tr:hover td:nth-child(1),
.work-table-v2 tbody tr:hover td:nth-child(2) {
  background: color-mix(
    in srgb,
    var(--soft) 76%,
    var(--panel)
  );
}

/* Preserve readability inside the frozen columns. */
.work-v2-context-line .work-cell-primary {
  flex: 0 0 auto;
  max-width: 155px;
}

.work-v2-context-detail {
  flex: 1 1 auto;
  min-width: 70px;
}

.work-v2-task-line .work-cell-primary {
  flex: 0 1 auto;
  max-width: 285px;
}

.work-v2-task-meta {
  flex: 0 0 auto;
}

.work-v2-task-detail {
  flex: 1 1 auto;
  min-width: 70px;
}

/* Never collapse primary content just because the right side needs space. */
@media (max-width: 1500px) {
  .work-table-v2 {
    width: 1430px;
    min-width: 1430px;
  }

  .work-v2-context-line .work-cell-primary {
    max-width: 150px;
  }

  .work-v2-task-line .work-cell-primary {
    max-width: 275px;
  }
}

@media (max-width: 900px) {
  .work-table-v2 {
    --flow-context-width: 280px;
    --flow-task-width: 500px;
    width: 1310px;
    min-width: 1310px;
  }

  .work-v2-context-line .work-cell-primary {
    max-width: 130px;
  }

  .work-v2-task-line .work-cell-primary {
    max-width: 240px;
  }
}

html[data-theme="dark"] .work-table-v2 thead th:nth-child(1),
html[data-theme="dark"] .work-table-v2 thead th:nth-child(2),
html[data-theme="dark"] .work-table-v2 tbody td:nth-child(1),
html[data-theme="dark"] .work-table-v2 tbody td:nth-child(2) {
  background: var(--panel);
}


/* Sticky layer + dark hover hotfix */

.work-zone-body {
  isolation: isolate;
}

.work-table-v2 {
  border-collapse: separate;
  border-spacing: 0;
}

.work-table-v2 thead th,
.work-table-v2 tbody td {
  background-clip: padding-box;
}

.work-table-v2 thead th:nth-child(n+3),
.work-table-v2 tbody td:nth-child(n+3) {
  position: relative;
  z-index: 1;
}

.work-table-v2 thead th:nth-child(1),
.work-table-v2 tbody td:nth-child(1),
.work-table-v2 thead th:nth-child(2),
.work-table-v2 tbody td:nth-child(2) {
  z-index: 20;
  overflow: hidden;
  background: var(--panel);
}

.work-table-v2 thead th:nth-child(1),
.work-table-v2 thead th:nth-child(2) {
  z-index: 30;
}

.work-table-v2 thead th:nth-child(2)::after,
.work-table-v2 tbody td:nth-child(2)::after {
  z-index: 31;
  right: -2px;
  width: 2px;
  box-shadow:
    8px 0 14px -10px rgba(15, 23, 42, .5);
}

/* Legacy inline-edit hover must not punch a light rectangle through Dark Mode. */
.work-table-v2 .work-day.work-inline-edit:hover,
.work-table-v2 .work-day.work-inline-edit:focus,
.work-table-v2 .work-day.work-inline-edit:focus-visible {
  background: var(--soft);
}

html[data-theme="dark"] .work-table-v2 .work-day.work-inline-edit:hover,
html[data-theme="dark"] .work-table-v2 .work-day.work-inline-edit:focus,
html[data-theme="dark"] .work-table-v2 .work-day.work-inline-edit:focus-visible {
  background: #1e2936;
  color: var(--ink);
  box-shadow: none;
}

html[data-theme="dark"] .work-table-v2 .work-day.work-inline-edit.carryover strong {
  color: #d97706;
}


/* Daily Flow viewport refinement
   Return more horizontal space to operational columns by reducing the sticky reading block. */

.work-table-v2 {
  --flow-context-width: 300px;
  --flow-task-width: 430px;
  width: 1280px;
  min-width: 1280px;
}

.work-v2-context-line .work-cell-primary {
  max-width: 140px;
}

.work-v2-task-line .work-cell-primary {
  max-width: 210px;
}

@media (max-width: 1500px) {
  .work-table-v2 {
    width: 1280px;
    min-width: 1280px;
  }

  .work-v2-context-line .work-cell-primary {
    max-width: 136px;
  }

  .work-v2-task-line .work-cell-primary {
    max-width: 205px;
  }
}

@media (max-width: 900px) {
  .work-table-v2 {
    --flow-context-width: 270px;
    --flow-task-width: 400px;
    width: 1220px;
    min-width: 1220px;
  }

  .work-v2-context-line .work-cell-primary {
    max-width: 122px;
  }

  .work-v2-task-line .work-cell-primary {
    max-width: 188px;
  }
}


/* Daily Flow server-side pagination */
.flow-pagebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 8px 12px;
  margin-top: 10px;
  border: 1px solid var(--ds-line);
  border-radius: 12px;
  background: var(--ds-surface);
  color: var(--ds-text-secondary);
  font-size: 11px;
}

.flow-pagebar > span b {
  color: var(--ds-text);
  font-weight: 700;
}

.flow-pagebar > div {
  display: flex;
  gap: 6px;
}

.flow-pagebar button {
  min-height: 32px;
  padding: 0 11px;
}

.flow-pagebar button:disabled {
  cursor: default;
  opacity: .42;
}

@media (max-width: 760px) {
  .flow-pagebar {
    align-items: stretch;
    flex-direction: column;
  }

  .flow-pagebar > div {
    width: 100%;
  }

  .flow-pagebar button {
    flex: 1;
  }
}
